001// -------------------------------------------------------------------------------- 002// Copyright 2002-2026 Echo Three, LLC 003// 004// Licensed under the Apache License, Version 2.0 (the "License"); 005// you may not use this file except in compliance with the License. 006// You may obtain a copy of the License at 007// 008// http://www.apache.org/licenses/LICENSE-2.0 009// 010// Unless required by applicable law or agreed to in writing, software 011// distributed under the License is distributed on an "AS IS" BASIS, 012// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013// See the License for the specific language governing permissions and 014// limitations under the License. 015// -------------------------------------------------------------------------------- 016// Generated File -- DO NOT EDIT BY HAND 017// -------------------------------------------------------------------------------- 018 019/** 020 * PartyApplicationEditorUseDetailFactory.java 021 */ 022 023package com.echothree.model.data.party.server.factory; 024 025import com.echothree.model.data.party.common.pk.PartyApplicationEditorUsePK; 026import com.echothree.model.data.party.common.pk.PartyPK; 027import com.echothree.model.data.core.common.pk.ApplicationEditorUsePK; 028import com.echothree.model.data.core.common.pk.ApplicationEditorPK; 029 030import com.echothree.model.data.party.server.entity.PartyApplicationEditorUse; 031import com.echothree.model.data.party.server.entity.Party; 032import com.echothree.model.data.core.server.entity.ApplicationEditorUse; 033import com.echothree.model.data.core.server.entity.ApplicationEditor; 034 035import com.echothree.model.data.party.common.PartyApplicationEditorUseDetailConstants; 036import com.echothree.model.data.party.common.pk.PartyApplicationEditorUseDetailPK; 037import com.echothree.model.data.party.server.value.PartyApplicationEditorUseDetailValue; 038import com.echothree.model.data.party.server.entity.PartyApplicationEditorUseDetail; 039import com.echothree.util.common.exception.PersistenceDatabaseException; 040import com.echothree.util.common.exception.PersistenceDatabaseUpdateException; 041import com.echothree.util.common.exception.PersistenceNotNullException; 042import com.echothree.util.server.persistence.BaseFactory; 043import com.echothree.util.server.persistence.EntityIdGenerator; 044import com.echothree.util.server.persistence.EntityPermission; 045import com.echothree.util.server.persistence.PersistenceDebugFlags; 046import com.echothree.util.server.persistence.Session; 047import java.sql.PreparedStatement; 048import java.sql.ResultSet; 049import java.sql.SQLException; 050import java.sql.Types; 051import java.io.ByteArrayInputStream; 052import java.io.StringReader; 053import java.util.ArrayList; 054import java.util.Collection; 055import java.util.HashSet; 056import java.util.List; 057import java.util.Map; 058import java.util.Set; 059import javax.enterprise.context.ApplicationScoped; 060import javax.enterprise.inject.spi.CDI; 061import javax.inject.Inject; 062import org.jooq.ResultQuery; 063import org.slf4j.Logger; 064import org.slf4j.LoggerFactory; 065 066@ApplicationScoped 067public class PartyApplicationEditorUseDetailFactory 068 implements BaseFactory<PartyApplicationEditorUseDetailPK, PartyApplicationEditorUseDetail> { 069 070 @Inject 071 Session session; 072 073 //private static final Logger log = LoggerFactory.getLogger(PartyApplicationEditorUseDetailFactory.class); 074 075 final private static String SQL_SELECT_READ_ONLY = "SELECT parappledtrusedt_partyapplicationeditorusedetailid, parappledtrusedt_parappledtruse_partyapplicationeditoruseid, parappledtrusedt_par_partyid, parappledtrusedt_appledtruse_applicationeditoruseid, parappledtrusedt_appledtr_applicationeditorid, parappledtrusedt_preferredheight, parappledtrusedt_preferredwidth, parappledtrusedt_fromtime, parappledtrusedt_thrutime FROM partyapplicationeditorusedetails WHERE parappledtrusedt_partyapplicationeditorusedetailid = ?"; 076 final private static String SQL_SELECT_READ_WRITE = "SELECT parappledtrusedt_partyapplicationeditorusedetailid, parappledtrusedt_parappledtruse_partyapplicationeditoruseid, parappledtrusedt_par_partyid, parappledtrusedt_appledtruse_applicationeditoruseid, parappledtrusedt_appledtr_applicationeditorid, parappledtrusedt_preferredheight, parappledtrusedt_preferredwidth, parappledtrusedt_fromtime, parappledtrusedt_thrutime FROM partyapplicationeditorusedetails WHERE parappledtrusedt_partyapplicationeditorusedetailid = ? FOR UPDATE"; 077 final private static String SQL_INSERT = "INSERT INTO partyapplicationeditorusedetails (parappledtrusedt_partyapplicationeditorusedetailid, parappledtrusedt_parappledtruse_partyapplicationeditoruseid, parappledtrusedt_par_partyid, parappledtrusedt_appledtruse_applicationeditoruseid, parappledtrusedt_appledtr_applicationeditorid, parappledtrusedt_preferredheight, parappledtrusedt_preferredwidth, parappledtrusedt_fromtime, parappledtrusedt_thrutime) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; 078 final private static String SQL_UPDATE = "UPDATE partyapplicationeditorusedetails SET parappledtrusedt_parappledtruse_partyapplicationeditoruseid = ?, parappledtrusedt_par_partyid = ?, parappledtrusedt_appledtruse_applicationeditoruseid = ?, parappledtrusedt_appledtr_applicationeditorid = ?, parappledtrusedt_preferredheight = ?, parappledtrusedt_preferredwidth = ?, parappledtrusedt_fromtime = ?, parappledtrusedt_thrutime = ? WHERE parappledtrusedt_partyapplicationeditorusedetailid = ?"; 079 final private static String SQL_DELETE = "DELETE FROM partyapplicationeditorusedetails WHERE parappledtrusedt_partyapplicationeditorusedetailid = ?"; 080 final private static String SQL_VALID = "SELECT COUNT(*) FROM partyapplicationeditorusedetails WHERE parappledtrusedt_partyapplicationeditorusedetailid = ?"; 081 082 final private static String PK_COLUMN = "parappledtrusedt_partyapplicationeditorusedetailid"; 083 final private static String ALL_COLUMNS = "parappledtrusedt_partyapplicationeditorusedetailid, parappledtrusedt_parappledtruse_partyapplicationeditoruseid, parappledtrusedt_par_partyid, parappledtrusedt_appledtruse_applicationeditoruseid, parappledtrusedt_appledtr_applicationeditorid, parappledtrusedt_preferredheight, parappledtrusedt_preferredwidth, parappledtrusedt_fromtime, parappledtrusedt_thrutime"; 084 final public static String TABLE_NAME = "partyapplicationeditorusedetails"; 085 086 final public static String PARAPPLEDTRUSEDT_PARTYAPPLICATIONEDITORUSEDETAILID = "parappledtrusedt_partyapplicationeditorusedetailid"; 087 final public static String PARAPPLEDTRUSEDT_PARAPPLEDTRUSE_PARTYAPPLICATIONEDITORUSEID = "parappledtrusedt_parappledtruse_partyapplicationeditoruseid"; 088 final public static String PARAPPLEDTRUSEDT_PAR_PARTYID = "parappledtrusedt_par_partyid"; 089 final public static String PARAPPLEDTRUSEDT_APPLEDTRUSE_APPLICATIONEDITORUSEID = "parappledtrusedt_appledtruse_applicationeditoruseid"; 090 final public static String PARAPPLEDTRUSEDT_APPLEDTR_APPLICATIONEDITORID = "parappledtrusedt_appledtr_applicationeditorid"; 091 final public static String PARAPPLEDTRUSEDT_PREFERREDHEIGHT = "parappledtrusedt_preferredheight"; 092 final public static String PARAPPLEDTRUSEDT_PREFERREDWIDTH = "parappledtrusedt_preferredwidth"; 093 final public static String PARAPPLEDTRUSEDT_FROMTIME = "parappledtrusedt_fromtime"; 094 final public static String PARAPPLEDTRUSEDT_THRUTIME = "parappledtrusedt_thrutime"; 095 096 final private static EntityIdGenerator entityIdGenerator = new EntityIdGenerator(PartyApplicationEditorUseDetailConstants.COMPONENT_VENDOR_NAME, PartyApplicationEditorUseDetailConstants.ENTITY_TYPE_NAME); 097 098 /** Creates a new instance of PartyApplicationEditorUseDetailFactory */ 099 protected PartyApplicationEditorUseDetailFactory() { 100 super(); 101 } 102 103 public static PartyApplicationEditorUseDetailFactory getInstance() { 104 return CDI.current().select(PartyApplicationEditorUseDetailFactory.class).get(); 105 } 106 107 @Override 108 public String getPKColumn() { 109 return PK_COLUMN; 110 } 111 112 @Override 113 public String getAllColumns() { 114 return ALL_COLUMNS; 115 } 116 117 @Override 118 public String getTableName() { 119 return TABLE_NAME; 120 } 121 122 @Override 123 public String getComponentVendorName() { 124 return PartyApplicationEditorUseDetailConstants.COMPONENT_VENDOR_NAME; 125 } 126 127 @Override 128 public String getEntityTypeName() { 129 return PartyApplicationEditorUseDetailConstants.ENTITY_TYPE_NAME; 130 } 131 132 public PreparedStatement prepareStatement(String query) { 133 return session.prepareStatement(PartyApplicationEditorUseDetailFactory.class, query); 134 } 135 136 public PartyApplicationEditorUseDetailPK getNextPK() { 137 return new PartyApplicationEditorUseDetailPK(entityIdGenerator.getNextEntityId()); 138 } 139 140 public Set<PartyApplicationEditorUseDetailPK> getPKsFromResultSetAsSet(ResultSet rs) 141 throws PersistenceDatabaseException { 142 Set<PartyApplicationEditorUseDetailPK> _result = new HashSet<>(); 143 144 try { 145 while(rs.next()) { 146 _result.add(getPKFromResultSet(rs)); 147 } 148 } catch (SQLException se) { 149 throw new PersistenceDatabaseException(se); 150 } 151 152 return _result; 153 } 154 155 public java.util.List<PartyApplicationEditorUseDetailPK> getPKsFromResultSetAsList(ResultSet rs) 156 throws PersistenceDatabaseException { 157 java.util.List<PartyApplicationEditorUseDetailPK> _result = new ArrayList<>(); 158 159 try { 160 while(rs.next()) { 161 _result.add(getPKFromResultSet(rs)); 162 } 163 } catch (SQLException se) { 164 throw new PersistenceDatabaseException(se); 165 } 166 167 return _result; 168 } 169 170 public PartyApplicationEditorUseDetailPK getPKFromResultSet(ResultSet rs) 171 throws PersistenceDatabaseException { 172 PartyApplicationEditorUseDetailPK _result; 173 174 try { 175 long parappledtrusedt_partyapplicationeditorusedetailid = rs.getLong(PARAPPLEDTRUSEDT_PARTYAPPLICATIONEDITORUSEDETAILID); 176 Long _entityId = rs.wasNull() ? null : parappledtrusedt_partyapplicationeditorusedetailid; 177 178 _result = new PartyApplicationEditorUseDetailPK(_entityId); 179 } catch (SQLException se) { 180 throw new PersistenceDatabaseException(se); 181 } 182 183 return _result; 184 } 185 186 public java.util.List<PartyApplicationEditorUseDetailValue> getValuesFromPKs(Collection<PartyApplicationEditorUseDetailPK> pks) 187 throws PersistenceDatabaseException { 188 java.util.List<PartyApplicationEditorUseDetailValue> _values = new ArrayList<>(pks.size()); 189 190 for(PartyApplicationEditorUseDetailPK _pk: pks) { 191 _values.add(getValueFromPK(_pk)); 192 } 193 194 return _values; 195 } 196 197 public PartyApplicationEditorUseDetailValue getValueFromPK(PartyApplicationEditorUseDetailPK pk) 198 throws PersistenceDatabaseException { 199 PartyApplicationEditorUseDetailValue _value; 200 201 // See if we already have the entity in the session cache 202 PartyApplicationEditorUseDetail _entity = (PartyApplicationEditorUseDetail)session.getEntity(pk); 203 if(_entity == null) 204 _value = getEntityFromPK(EntityPermission.READ_ONLY, pk).getPartyApplicationEditorUseDetailValue(); 205 else 206 _value = _entity.getPartyApplicationEditorUseDetailValue(); 207 208 return _value; 209 } 210 211 public java.util.List<PartyApplicationEditorUseDetailValue> getValuesFromResultSet(ResultSet rs) 212 throws PersistenceDatabaseException { 213 java.util.List<PartyApplicationEditorUseDetailValue> _result = new ArrayList<>(); 214 215 try { 216 while(rs.next()) { 217 _result.add(getValueFromResultSet(rs)); 218 } 219 } catch (SQLException se) { 220 throw new PersistenceDatabaseException(se); 221 } 222 223 return _result; 224 } 225 226 public PartyApplicationEditorUseDetailValue getValueFromResultSet(ResultSet rs) 227 throws PersistenceDatabaseException { 228 PartyApplicationEditorUseDetailValue _value; 229 230 try { 231 Long parappledtrusedt_partyapplicationeditorusedetailid = rs.getLong(PARAPPLEDTRUSEDT_PARTYAPPLICATIONEDITORUSEDETAILID); 232 PartyApplicationEditorUseDetailPK _pk = new PartyApplicationEditorUseDetailPK(parappledtrusedt_partyapplicationeditorusedetailid); 233 234 // See if we already have the entity in the session cache 235 PartyApplicationEditorUseDetail _entity = (PartyApplicationEditorUseDetail)session.getEntity(_pk); 236 237 if(_entity == null) { 238 Long parappledtrusedt_parappledtruse_partyapplicationeditoruseid = rs.getLong(PARAPPLEDTRUSEDT_PARAPPLEDTRUSE_PARTYAPPLICATIONEDITORUSEID); 239 if(rs.wasNull()) 240 parappledtrusedt_parappledtruse_partyapplicationeditoruseid = null; 241 242 Long parappledtrusedt_par_partyid = rs.getLong(PARAPPLEDTRUSEDT_PAR_PARTYID); 243 if(rs.wasNull()) 244 parappledtrusedt_par_partyid = null; 245 246 Long parappledtrusedt_appledtruse_applicationeditoruseid = rs.getLong(PARAPPLEDTRUSEDT_APPLEDTRUSE_APPLICATIONEDITORUSEID); 247 if(rs.wasNull()) 248 parappledtrusedt_appledtruse_applicationeditoruseid = null; 249 250 Long parappledtrusedt_appledtr_applicationeditorid = rs.getLong(PARAPPLEDTRUSEDT_APPLEDTR_APPLICATIONEDITORID); 251 if(rs.wasNull()) 252 parappledtrusedt_appledtr_applicationeditorid = null; 253 254 Integer parappledtrusedt_preferredheight = rs.getInt(PARAPPLEDTRUSEDT_PREFERREDHEIGHT); 255 if(rs.wasNull()) 256 parappledtrusedt_preferredheight = null; 257 258 Integer parappledtrusedt_preferredwidth = rs.getInt(PARAPPLEDTRUSEDT_PREFERREDWIDTH); 259 if(rs.wasNull()) 260 parappledtrusedt_preferredwidth = null; 261 262 Long parappledtrusedt_fromtime = rs.getLong(PARAPPLEDTRUSEDT_FROMTIME); 263 if(rs.wasNull()) 264 parappledtrusedt_fromtime = null; 265 266 Long parappledtrusedt_thrutime = rs.getLong(PARAPPLEDTRUSEDT_THRUTIME); 267 if(rs.wasNull()) 268 parappledtrusedt_thrutime = null; 269 270 _value = new PartyApplicationEditorUseDetailValue(_pk, new PartyApplicationEditorUsePK(parappledtrusedt_parappledtruse_partyapplicationeditoruseid), new PartyPK(parappledtrusedt_par_partyid), new ApplicationEditorUsePK(parappledtrusedt_appledtruse_applicationeditoruseid), new ApplicationEditorPK(parappledtrusedt_appledtr_applicationeditorid), parappledtrusedt_preferredheight, parappledtrusedt_preferredwidth, parappledtrusedt_fromtime, parappledtrusedt_thrutime); 271 } else 272 _value = _entity.getPartyApplicationEditorUseDetailValue(); 273 } catch (SQLException se) { 274 throw new PersistenceDatabaseException(se); 275 } 276 277 return _value; 278 } 279 280 public java.util.List<PartyApplicationEditorUseDetail> getEntitiesFromPKs(EntityPermission entityPermission, Collection<PartyApplicationEditorUseDetailPK> pks) 281 throws PersistenceDatabaseException { 282 java.util.List<PartyApplicationEditorUseDetail> _entities = new ArrayList<>(pks.size()); 283 284 for(PartyApplicationEditorUseDetailPK _pk: pks) { 285 _entities.add(getEntityFromPK(entityPermission, _pk)); 286 } 287 288 return _entities; 289 } 290 291 public PartyApplicationEditorUseDetail getEntityFromValue(EntityPermission entityPermission, PartyApplicationEditorUseDetailValue value) { 292 return getEntityFromPK(entityPermission, value.getPrimaryKey()); 293 } 294 295 public PartyApplicationEditorUseDetail getEntityFromCache(PartyApplicationEditorUseDetailPK pk) { 296 PartyApplicationEditorUseDetailValue _value = (PartyApplicationEditorUseDetailValue)session.getValueCache().get(pk); 297 298 return _value == null ? null : new PartyApplicationEditorUseDetail(_value, EntityPermission.READ_ONLY); 299 } 300 301 public PartyApplicationEditorUseDetail getEntityFromPK(EntityPermission entityPermission, PartyApplicationEditorUseDetailPK pk) 302 throws PersistenceDatabaseException { 303 PartyApplicationEditorUseDetail _entity; 304 305 // See if we already have the entity in the session cache 306 _entity = (PartyApplicationEditorUseDetail)session.getEntity(pk); 307 if(_entity != null) { 308 // If the requested permission is READ_WRITE, and the cached permission is 309 // READ_ONLY, then pretend that the cached object wasn't found, and create 310 // a new entity that is READ_WRITE. 311 if(entityPermission.equals(EntityPermission.READ_WRITE)) { 312 if(_entity.getEntityPermission().equals(EntityPermission.READ_ONLY)) 313 _entity = null; 314 } 315 } 316 317 if(_entity == null && entityPermission.equals(EntityPermission.READ_ONLY)) { 318 _entity = getEntityFromCache(pk); 319 } 320 321 if(_entity == null) { 322 PreparedStatement _ps = session.prepareStatement(entityPermission.equals(EntityPermission.READ_ONLY)? SQL_SELECT_READ_ONLY: SQL_SELECT_READ_WRITE); 323 long _entityId = pk.getEntityId(); 324 ResultSet _rs = null; 325 326 try { 327 _ps.setLong(1, _entityId); 328 _rs = _ps.executeQuery(); 329 if(_rs.next()) { 330 _entity = getEntityFromResultSet(entityPermission, _rs); 331 } 332 } catch (SQLException se) { 333 throw new PersistenceDatabaseException(se); 334 } finally { 335 if(_rs != null) { 336 try { 337 _rs.close(); 338 } catch (SQLException se) { 339 // do nothing 340 } 341 } 342 } 343 } 344 345 return _entity; 346 } 347 348 public Set<PartyApplicationEditorUseDetailPK> getPKsFromQueryAsSet(PreparedStatement ps, final Object... params) 349 throws PersistenceDatabaseException { 350 Set<PartyApplicationEditorUseDetailPK> _pks; 351 ResultSet _rs = null; 352 353 try { 354 if(params.length != 0) { 355 Session.setQueryParams(ps, params); 356 } 357 358 _rs = ps.executeQuery(); 359 _pks = getPKsFromResultSetAsSet(_rs); 360 _rs.close(); 361 } catch (SQLException se) { 362 throw new PersistenceDatabaseException(se); 363 } finally { 364 if(_rs != null) { 365 try { 366 _rs.close(); 367 } catch (SQLException se) { 368 // do nothing 369 } 370 } 371 } 372 373 return _pks; 374 } 375 376 public java.util.List<PartyApplicationEditorUseDetailPK> getPKsFromQueryAsList(PreparedStatement ps, final Object... params) 377 throws PersistenceDatabaseException { 378 java.util.List<PartyApplicationEditorUseDetailPK> _pks; 379 ResultSet _rs = null; 380 381 try { 382 if(params.length != 0) { 383 Session.setQueryParams(ps, params); 384 } 385 386 _rs = ps.executeQuery(); 387 _pks = getPKsFromResultSetAsList(_rs); 388 _rs.close(); 389 } catch (SQLException se) { 390 throw new PersistenceDatabaseException(se); 391 } finally { 392 if(_rs != null) { 393 try { 394 _rs.close(); 395 } catch (SQLException se) { 396 // do nothing 397 } 398 } 399 } 400 401 return _pks; 402 } 403 404 public PartyApplicationEditorUseDetailPK getPKFromQuery(PreparedStatement ps, final Object... params) 405 throws PersistenceDatabaseException { 406 PartyApplicationEditorUseDetailPK _pk = null; 407 ResultSet _rs = null; 408 409 try { 410 if(params.length != 0) { 411 Session.setQueryParams(ps, params); 412 } 413 414 _rs = ps.executeQuery(); 415 if(_rs.next()) { 416 _pk = getPKFromResultSet(_rs); 417 } 418 _rs.close(); 419 } catch (SQLException se) { 420 throw new PersistenceDatabaseException(se); 421 } finally { 422 if(_rs != null) { 423 try { 424 _rs.close(); 425 } catch (SQLException se) { 426 // do nothing 427 } 428 } 429 } 430 431 return _pk; 432 } 433 434 public java.util.List<PartyApplicationEditorUseDetail> getEntitiesFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap, final Object... params) 435 throws PersistenceDatabaseException { 436 PreparedStatement ps = session.prepareStatement(PartyApplicationEditorUseDetailFactory.class, queryMap.get(entityPermission)); 437 438 return getEntitiesFromQuery(entityPermission, ps, params); 439 } 440 441 public java.util.List<PartyApplicationEditorUseDetail> getEntitiesFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap) 442 throws PersistenceDatabaseException { 443 PreparedStatement ps = session.prepareStatement(PartyApplicationEditorUseDetailFactory.class, queryMap.get(entityPermission)); 444 445 return getEntitiesFromQuery(entityPermission, ps); 446 } 447 448 public java.util.List<PartyApplicationEditorUseDetail> getEntitiesFromQuery(EntityPermission entityPermission, ResultQuery<?> query) 449 throws PersistenceDatabaseException { 450 PreparedStatement ps = session.prepareStatement(PartyApplicationEditorUseDetailFactory.class, query.getSQL()); 451 452 return getEntitiesFromQuery(entityPermission, ps, query.getBindValues().toArray()); 453 } 454 455 public java.util.List<PartyApplicationEditorUseDetail> getEntitiesFromQuery(EntityPermission entityPermission, PreparedStatement ps, final Object... params) 456 throws PersistenceDatabaseException { 457 java.util.List<PartyApplicationEditorUseDetail> _entities; 458 ResultSet _rs = null; 459 460 try { 461 if(params.length != 0) { 462 Session.setQueryParams(ps, params); 463 } 464 465 _rs = ps.executeQuery(); 466 _entities = getEntitiesFromResultSet(entityPermission, _rs); 467 _rs.close(); 468 } catch (SQLException se) { 469 throw new PersistenceDatabaseException(se); 470 } finally { 471 if(_rs != null) { 472 try { 473 _rs.close(); 474 } catch (SQLException se) { 475 // do nothing 476 } 477 } 478 } 479 480 return _entities; 481 } 482 483 public PartyApplicationEditorUseDetail getEntityFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap, final Object... params) 484 throws PersistenceDatabaseException { 485 PreparedStatement ps = session.prepareStatement(PartyApplicationEditorUseDetailFactory.class, queryMap.get(entityPermission)); 486 487 return getEntityFromQuery(entityPermission, ps, params); 488 } 489 490 public PartyApplicationEditorUseDetail getEntityFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap) 491 throws PersistenceDatabaseException { 492 PreparedStatement ps = session.prepareStatement(PartyApplicationEditorUseDetailFactory.class, queryMap.get(entityPermission)); 493 494 return getEntityFromQuery(entityPermission, ps); 495 } 496 497 public PartyApplicationEditorUseDetail getEntityFromQuery(EntityPermission entityPermission, ResultQuery<?> query) 498 throws PersistenceDatabaseException { 499 PreparedStatement ps = session.prepareStatement(PartyApplicationEditorUseDetailFactory.class, query.getSQL()); 500 501 return getEntityFromQuery(entityPermission, ps, query.getBindValues().toArray()); 502 } 503 504 public PartyApplicationEditorUseDetail getEntityFromQuery(EntityPermission entityPermission, PreparedStatement ps, final Object... params) 505 throws PersistenceDatabaseException { 506 PartyApplicationEditorUseDetail _entity = null; 507 ResultSet _rs = null; 508 509 try { 510 if(params.length != 0) { 511 Session.setQueryParams(ps, params); 512 } 513 514 _rs = ps.executeQuery(); 515 if(_rs.next()) { 516 _entity = getEntityFromResultSet(entityPermission, _rs); 517 } 518 _rs.close(); 519 } catch (SQLException se) { 520 throw new PersistenceDatabaseException(se); 521 } finally { 522 if(_rs != null) { 523 try { 524 _rs.close(); 525 } catch (SQLException se) { 526 // do nothing 527 } 528 } 529 } 530 531 return _entity; 532 } 533 534 public java.util.List<PartyApplicationEditorUseDetail> getEntitiesFromResultSet(EntityPermission entityPermission, ResultSet rs) 535 throws PersistenceDatabaseException { 536 java.util.List<PartyApplicationEditorUseDetail> _result = new ArrayList<>(); 537 538 try { 539 while(rs.next()) { 540 _result.add(getEntityFromResultSet(entityPermission, rs)); 541 } 542 } catch (SQLException se) { 543 throw new PersistenceDatabaseException(se); 544 } 545 546 return _result; 547 } 548 549 public PartyApplicationEditorUseDetail getEntityFromResultSet(EntityPermission entityPermission, ResultSet rs) 550 throws PersistenceDatabaseException { 551 PartyApplicationEditorUseDetail _entity; 552 553 try { 554 Long parappledtrusedt_partyapplicationeditorusedetailid = rs.getLong(PARAPPLEDTRUSEDT_PARTYAPPLICATIONEDITORUSEDETAILID); 555 PartyApplicationEditorUseDetailPK _pk = new PartyApplicationEditorUseDetailPK(parappledtrusedt_partyapplicationeditorusedetailid); 556 557 // See if we already have the entity in the session cache 558 _entity = (PartyApplicationEditorUseDetail)session.getEntity(_pk); 559 if(_entity != null) { 560 // If the requested permission is READ_WRITE, and the cached permission is 561 // READ_ONLY, then pretend that the cached object wasn't found, and create 562 // a new entity that is READ_WRITE. 563 if(entityPermission.equals(EntityPermission.READ_WRITE)) { 564 if(_entity.getEntityPermission().equals(EntityPermission.READ_ONLY)) 565 _entity = null; 566 } 567 } 568 boolean foundInSessionCache = _entity != null; 569 570 if(_entity == null && entityPermission.equals(EntityPermission.READ_ONLY)) { 571 _entity = getEntityFromCache(_pk); 572 } 573 574 if(_entity == null) { 575 Long parappledtrusedt_parappledtruse_partyapplicationeditoruseid = rs.getLong(PARAPPLEDTRUSEDT_PARAPPLEDTRUSE_PARTYAPPLICATIONEDITORUSEID); 576 if(rs.wasNull()) 577 parappledtrusedt_parappledtruse_partyapplicationeditoruseid = null; 578 579 Long parappledtrusedt_par_partyid = rs.getLong(PARAPPLEDTRUSEDT_PAR_PARTYID); 580 if(rs.wasNull()) 581 parappledtrusedt_par_partyid = null; 582 583 Long parappledtrusedt_appledtruse_applicationeditoruseid = rs.getLong(PARAPPLEDTRUSEDT_APPLEDTRUSE_APPLICATIONEDITORUSEID); 584 if(rs.wasNull()) 585 parappledtrusedt_appledtruse_applicationeditoruseid = null; 586 587 Long parappledtrusedt_appledtr_applicationeditorid = rs.getLong(PARAPPLEDTRUSEDT_APPLEDTR_APPLICATIONEDITORID); 588 if(rs.wasNull()) 589 parappledtrusedt_appledtr_applicationeditorid = null; 590 591 Integer parappledtrusedt_preferredheight = rs.getInt(PARAPPLEDTRUSEDT_PREFERREDHEIGHT); 592 if(rs.wasNull()) 593 parappledtrusedt_preferredheight = null; 594 595 Integer parappledtrusedt_preferredwidth = rs.getInt(PARAPPLEDTRUSEDT_PREFERREDWIDTH); 596 if(rs.wasNull()) 597 parappledtrusedt_preferredwidth = null; 598 599 Long parappledtrusedt_fromtime = rs.getLong(PARAPPLEDTRUSEDT_FROMTIME); 600 if(rs.wasNull()) 601 parappledtrusedt_fromtime = null; 602 603 Long parappledtrusedt_thrutime = rs.getLong(PARAPPLEDTRUSEDT_THRUTIME); 604 if(rs.wasNull()) 605 parappledtrusedt_thrutime = null; 606 607 PartyApplicationEditorUseDetailValue _value = new PartyApplicationEditorUseDetailValue(_pk, parappledtrusedt_parappledtruse_partyapplicationeditoruseid == null? null: new PartyApplicationEditorUsePK(parappledtrusedt_parappledtruse_partyapplicationeditoruseid), parappledtrusedt_par_partyid == null? null: new PartyPK(parappledtrusedt_par_partyid), parappledtrusedt_appledtruse_applicationeditoruseid == null? null: new ApplicationEditorUsePK(parappledtrusedt_appledtruse_applicationeditoruseid), parappledtrusedt_appledtr_applicationeditorid == null? null: new ApplicationEditorPK(parappledtrusedt_appledtr_applicationeditorid), parappledtrusedt_preferredheight, parappledtrusedt_preferredwidth, parappledtrusedt_fromtime, parappledtrusedt_thrutime); 608 _entity = new PartyApplicationEditorUseDetail(_value, entityPermission); 609 } 610 611 if(!foundInSessionCache) { 612 if(entityPermission.equals(EntityPermission.READ_ONLY)) { 613 session.putReadOnlyEntity(_pk, _entity); 614 session.getValueCache().put(_entity.getPartyApplicationEditorUseDetailValue()); 615 } else { 616 session.putReadWriteEntity(_pk, _entity); 617 } 618 } 619 } catch (SQLException se) { 620 throw new PersistenceDatabaseException(se); 621 } 622 623 return _entity; 624 } 625 626 public PartyApplicationEditorUseDetail create(PartyApplicationEditorUse partyApplicationEditorUse, Party party, ApplicationEditorUse applicationEditorUse, ApplicationEditor applicationEditor, Integer preferredHeight, Integer preferredWidth, Long fromTime, Long thruTime) 627 throws PersistenceDatabaseException, PersistenceNotNullException { 628 return create(partyApplicationEditorUse == null ? null : partyApplicationEditorUse.getPrimaryKey(), party == null ? null : party.getPrimaryKey(), applicationEditorUse == null ? null : applicationEditorUse.getPrimaryKey(), applicationEditor == null ? null : applicationEditor.getPrimaryKey(), preferredHeight, preferredWidth, fromTime, thruTime); 629 } 630 631 private void bindForCreate(PreparedStatement _ps, PartyApplicationEditorUseDetailValue _value) 632 throws SQLException { 633 _ps.setLong(1, _value.getEntityId()); 634 635 PartyApplicationEditorUsePK parappledtrusedt_parappledtruse_partyapplicationeditoruseid = _value.getPartyApplicationEditorUsePK(); 636 if(parappledtrusedt_parappledtruse_partyapplicationeditoruseid == null) 637 _ps.setNull(2, Types.BIGINT); 638 else 639 _ps.setLong(2, parappledtrusedt_parappledtruse_partyapplicationeditoruseid.getEntityId()); 640 641 PartyPK parappledtrusedt_par_partyid = _value.getPartyPK(); 642 if(parappledtrusedt_par_partyid == null) 643 _ps.setNull(3, Types.BIGINT); 644 else 645 _ps.setLong(3, parappledtrusedt_par_partyid.getEntityId()); 646 647 ApplicationEditorUsePK parappledtrusedt_appledtruse_applicationeditoruseid = _value.getApplicationEditorUsePK(); 648 if(parappledtrusedt_appledtruse_applicationeditoruseid == null) 649 _ps.setNull(4, Types.BIGINT); 650 else 651 _ps.setLong(4, parappledtrusedt_appledtruse_applicationeditoruseid.getEntityId()); 652 653 ApplicationEditorPK parappledtrusedt_appledtr_applicationeditorid = _value.getApplicationEditorPK(); 654 if(parappledtrusedt_appledtr_applicationeditorid == null) 655 _ps.setNull(5, Types.BIGINT); 656 else 657 _ps.setLong(5, parappledtrusedt_appledtr_applicationeditorid.getEntityId()); 658 659 Integer parappledtrusedt_preferredheight = _value.getPreferredHeight(); 660 if(parappledtrusedt_preferredheight == null) 661 _ps.setNull(6, Types.INTEGER); 662 else 663 _ps.setInt(6, parappledtrusedt_preferredheight); 664 665 Integer parappledtrusedt_preferredwidth = _value.getPreferredWidth(); 666 if(parappledtrusedt_preferredwidth == null) 667 _ps.setNull(7, Types.INTEGER); 668 else 669 _ps.setInt(7, parappledtrusedt_preferredwidth); 670 671 Long parappledtrusedt_fromtime = _value.getFromTime(); 672 if(parappledtrusedt_fromtime == null) 673 _ps.setNull(8, Types.BIGINT); 674 else 675 _ps.setLong(8, parappledtrusedt_fromtime); 676 677 Long parappledtrusedt_thrutime = _value.getThruTime(); 678 if(parappledtrusedt_thrutime == null) 679 _ps.setNull(9, Types.BIGINT); 680 else 681 _ps.setLong(9, parappledtrusedt_thrutime); 682 683 } 684 685 public PartyApplicationEditorUseDetail create(PartyApplicationEditorUsePK partyApplicationEditorUsePK, PartyPK partyPK, ApplicationEditorUsePK applicationEditorUsePK, ApplicationEditorPK applicationEditorPK, Integer preferredHeight, Integer preferredWidth, Long fromTime, Long thruTime) 686 throws PersistenceDatabaseException, PersistenceNotNullException { 687 PartyApplicationEditorUseDetailPK _pk = getNextPK(); 688 PartyApplicationEditorUseDetailValue _value = new PartyApplicationEditorUseDetailValue(_pk, partyApplicationEditorUsePK, partyPK, applicationEditorUsePK, applicationEditorPK, preferredHeight, preferredWidth, fromTime, thruTime); 689 690 PreparedStatement _ps = session.prepareStatement(SQL_INSERT); 691 692 try { 693 bindForCreate(_ps, _value); 694 695 if(PersistenceDebugFlags.CheckEntityInsertRowCount) { 696 int _count = _ps.executeUpdate(); 697 698 if(_count != 1) { 699 throw new PersistenceDatabaseUpdateException("insert failed, _count = " + _count); 700 } 701 } else { 702 _ps.executeUpdate(); 703 } 704 705 session.getValueCache().put(_value); 706 } catch (SQLException se) { 707 throw new PersistenceDatabaseException(se); 708 } 709 710 PartyApplicationEditorUseDetail _entity = new PartyApplicationEditorUseDetail(_value, EntityPermission.READ_ONLY); 711 session.putReadOnlyEntity(_pk, _entity); 712 713 return _entity; 714 } 715 716 public void create(Collection<PartyApplicationEditorUseDetailValue> _values) 717 throws PersistenceDatabaseException, PersistenceNotNullException { 718 int _size = _values.size(); 719 720 if(_size > 0) { 721 PreparedStatement _ps = session.prepareStatement(SQL_INSERT); 722 List<PartyApplicationEditorUseDetailValue> _cacheValues = new ArrayList<>(_size); 723 724 try { 725 for(PartyApplicationEditorUseDetailValue _value : _values) { 726 _value.setEntityId(entityIdGenerator.getNextEntityId()); 727 bindForCreate(_ps, _value); 728 729 _ps.addBatch(); 730 731 _cacheValues.add(_value); 732 } 733 734 if(PersistenceDebugFlags.CheckEntityInsertRowCount) { 735 int[] _counts = _ps.executeBatch(); 736 737 for(int _countOffset = 0 ; _countOffset < _size ; _countOffset++) { 738 if(_counts[_countOffset] != 1 && _counts[_countOffset] != PreparedStatement.SUCCESS_NO_INFO) { 739 throw new PersistenceDatabaseUpdateException("batch insert failed, _counts[" + _countOffset + "] = " + _counts[_countOffset]); 740 } 741 } 742 } else { 743 _ps.executeBatch(); 744 } 745 746 _ps.clearBatch(); 747 } catch (SQLException se) { 748 throw new PersistenceDatabaseException(se); 749 } 750 751 _cacheValues.forEach((_cacheValue) -> { 752 PartyApplicationEditorUseDetail _cacheEntity = new PartyApplicationEditorUseDetail(_cacheValue, EntityPermission.READ_ONLY); 753 754 session.putReadOnlyEntity(_cacheValue.getPrimaryKey(), _cacheEntity); 755 }); 756 } 757 } 758 759 private boolean bindForStore(PreparedStatement _ps, PartyApplicationEditorUseDetailValue _value) 760 throws SQLException { 761 boolean _hasBeenModified = _value.hasBeenModified(); 762 763 if(_hasBeenModified) { 764 PartyApplicationEditorUsePK parappledtrusedt_parappledtruse_partyapplicationeditoruseid = _value.getPartyApplicationEditorUsePK(); 765 if(parappledtrusedt_parappledtruse_partyapplicationeditoruseid == null) 766 _ps.setNull(1, Types.BIGINT); 767 else 768 _ps.setLong(1, parappledtrusedt_parappledtruse_partyapplicationeditoruseid.getEntityId()); 769 770 PartyPK parappledtrusedt_par_partyid = _value.getPartyPK(); 771 if(parappledtrusedt_par_partyid == null) 772 _ps.setNull(2, Types.BIGINT); 773 else 774 _ps.setLong(2, parappledtrusedt_par_partyid.getEntityId()); 775 776 ApplicationEditorUsePK parappledtrusedt_appledtruse_applicationeditoruseid = _value.getApplicationEditorUsePK(); 777 if(parappledtrusedt_appledtruse_applicationeditoruseid == null) 778 _ps.setNull(3, Types.BIGINT); 779 else 780 _ps.setLong(3, parappledtrusedt_appledtruse_applicationeditoruseid.getEntityId()); 781 782 ApplicationEditorPK parappledtrusedt_appledtr_applicationeditorid = _value.getApplicationEditorPK(); 783 if(parappledtrusedt_appledtr_applicationeditorid == null) 784 _ps.setNull(4, Types.BIGINT); 785 else 786 _ps.setLong(4, parappledtrusedt_appledtr_applicationeditorid.getEntityId()); 787 788 Integer parappledtrusedt_preferredheight = _value.getPreferredHeight(); 789 if(parappledtrusedt_preferredheight == null) 790 _ps.setNull(5, Types.INTEGER); 791 else 792 _ps.setInt(5, parappledtrusedt_preferredheight); 793 794 Integer parappledtrusedt_preferredwidth = _value.getPreferredWidth(); 795 if(parappledtrusedt_preferredwidth == null) 796 _ps.setNull(6, Types.INTEGER); 797 else 798 _ps.setInt(6, parappledtrusedt_preferredwidth); 799 800 Long parappledtrusedt_fromtime = _value.getFromTime(); 801 if(parappledtrusedt_fromtime == null) 802 _ps.setNull(7, Types.BIGINT); 803 else 804 _ps.setLong(7, parappledtrusedt_fromtime); 805 806 Long parappledtrusedt_thrutime = _value.getThruTime(); 807 if(parappledtrusedt_thrutime == null) 808 _ps.setNull(8, Types.BIGINT); 809 else 810 _ps.setLong(8, parappledtrusedt_thrutime); 811 812 _ps.setLong(9, _value.getPrimaryKey().getEntityId()); 813 814 _value.clearHasBeenModified(); 815 } 816 817 return _hasBeenModified; 818 } 819 820 @Override 821 public void store(PartyApplicationEditorUseDetail entity) 822 throws PersistenceDatabaseException { 823 PreparedStatement _ps = session.prepareStatement(SQL_UPDATE); 824 825 try { 826 PartyApplicationEditorUseDetailValue _value = entity.getPartyApplicationEditorUseDetailValue(); 827 828 if(bindForStore(_ps, _value)) { 829 if(PersistenceDebugFlags.CheckEntityUpdateRowCount) { 830 int _count = _ps.executeUpdate(); 831 832 if(_count != 1) { 833 throw new PersistenceDatabaseUpdateException("update failed, _count = " + _count); 834 } 835 } else { 836 _ps.executeUpdate(); 837 } 838 839 session.getValueCache().put(_value); 840 } 841 } catch (SQLException se) { 842 throw new PersistenceDatabaseException(se); 843 } 844 } 845 846 @Override 847 public void store(Collection<PartyApplicationEditorUseDetail> entities) 848 throws PersistenceDatabaseException { 849 if(entities.size() > 0) { 850 PreparedStatement _ps = session.prepareStatement(SQL_UPDATE); 851 int _modifiedEntities = 0; 852 853 try { 854 for(PartyApplicationEditorUseDetail entity : entities) { 855 if(bindForStore(_ps, entity.getPartyApplicationEditorUseDetailValue())) { 856 _ps.addBatch(); 857 _modifiedEntities++; 858 } 859 } 860 861 if(_modifiedEntities != 0) { 862 if(PersistenceDebugFlags.CheckEntityUpdateRowCount) { 863 int[] _counts = _ps.executeBatch(); 864 865 for(int _countOffset = 0 ; _countOffset < _modifiedEntities ; _countOffset++) { 866 if(_counts[_countOffset] != 1 && _counts[_countOffset] != PreparedStatement.SUCCESS_NO_INFO) { 867 throw new PersistenceDatabaseUpdateException("batch update failed, _counts[" + _countOffset + "] = " + _counts[_countOffset]); 868 } 869 } 870 } else { 871 _ps.executeBatch(); 872 } 873 874 _ps.clearBatch(); 875 876 entities.forEach((entity) -> { 877 session.getValueCache().put(entity.getPartyApplicationEditorUseDetailValue()); 878 }); 879 } 880 } catch (SQLException se) { 881 throw new PersistenceDatabaseException(se); 882 } 883 } 884 } 885 886 @Override 887 public void remove(PartyApplicationEditorUseDetail entity) 888 throws PersistenceDatabaseException { 889 remove(entity.getPrimaryKey()); 890 } 891 892 @Override 893 public void remove(PartyApplicationEditorUseDetailPK pk) 894 throws PersistenceDatabaseException { 895 PreparedStatement _ps = session.prepareStatement(SQL_DELETE); 896 long _entityId = pk.getEntityId(); 897 898 try { 899 _ps.setLong(1, _entityId); 900 901 if(PersistenceDebugFlags.CheckEntityDeleteRowCount) { 902 int _count = _ps.executeUpdate(); 903 904 if(_count != 1) { 905 throw new PersistenceDatabaseUpdateException("remove failed, _count = " + _count); 906 } 907 } else { 908 _ps.executeUpdate(); 909 } 910 911 session.getValueCache().remove(pk); 912 } catch (SQLException se) { 913 throw new PersistenceDatabaseException(se); 914 } 915 916 session.removed(pk, false); 917 } 918 919 @Override 920 public void remove(Collection<PartyApplicationEditorUseDetailPK> pks) 921 throws PersistenceDatabaseException { 922 if(pks.size() > 0) { 923 PreparedStatement _ps = session.prepareStatement(SQL_DELETE); 924 int _modifiedEntities = 0; 925 926 try { 927 for(PartyApplicationEditorUseDetailPK pk : pks) { 928 long _entityId = pk.getEntityId(); 929 930 _ps.setLong(1, _entityId); 931 932 _ps.addBatch(); 933 _modifiedEntities++; 934 } 935 936 if(_modifiedEntities != 0) { 937 if(PersistenceDebugFlags.CheckEntityDeleteRowCount) { 938 int[] _counts = _ps.executeBatch(); 939 940 for(int _countOffset = 0 ; _countOffset < _modifiedEntities ; _countOffset++) { 941 if(_counts[_countOffset] != 1 && _counts[_countOffset] != PreparedStatement.SUCCESS_NO_INFO) { 942 throw new PersistenceDatabaseUpdateException("batch remove failed, _counts[" + _countOffset + "] = " + _counts[_countOffset]); 943 } 944 } 945 } else { 946 _ps.executeBatch(); 947 } 948 949 _ps.clearBatch(); 950 951 pks.forEach((pk) -> { 952 session.getValueCache().remove(pk); 953 }); 954 } 955 } catch (SQLException se) { 956 throw new PersistenceDatabaseException(se); 957 } 958 959 pks.forEach((pk) -> { 960 session.removed(pk, true); 961 }); 962 } 963 } 964 965 @Override 966 public boolean validPK(PartyApplicationEditorUseDetailPK pk) 967 throws PersistenceDatabaseException { 968 boolean valid = false; 969 PreparedStatement _ps = session.prepareStatement(SQL_VALID); 970 ResultSet _rs = null; 971 972 try { 973 _ps.setLong(1, pk.getEntityId()); 974 975 _rs = _ps.executeQuery(); 976 if(_rs.next()) { 977 long _count = _rs.getLong(1); 978 if(_rs.wasNull()) 979 _count = 0; 980 981 if(_count == 1) 982 valid = true; 983 } 984 } catch (SQLException se) { 985 throw new PersistenceDatabaseException(se); 986 } finally { 987 if(_rs != null) { 988 try { 989 _rs.close(); 990 } catch (SQLException se) { 991 // do nothing 992 } 993 } 994 } 995 996 return valid; 997 } 998 999}