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 * TrainingClassDetailFactory.java 021 */ 022 023package com.echothree.model.data.training.server.factory; 024 025import com.echothree.model.data.training.common.pk.TrainingClassPK; 026import com.echothree.model.data.workeffort.common.pk.WorkEffortScopePK; 027 028import com.echothree.model.data.training.server.entity.TrainingClass; 029import com.echothree.model.data.workeffort.server.entity.WorkEffortScope; 030 031import com.echothree.model.data.training.common.TrainingClassDetailConstants; 032import com.echothree.model.data.training.common.pk.TrainingClassDetailPK; 033import com.echothree.model.data.training.server.value.TrainingClassDetailValue; 034import com.echothree.model.data.training.server.entity.TrainingClassDetail; 035import com.echothree.util.common.exception.PersistenceDatabaseException; 036import com.echothree.util.common.exception.PersistenceDatabaseUpdateException; 037import com.echothree.util.common.exception.PersistenceNotNullException; 038import com.echothree.util.server.persistence.BaseFactory; 039import com.echothree.util.server.persistence.EntityIdGenerator; 040import com.echothree.util.server.persistence.EntityPermission; 041import com.echothree.util.server.persistence.PersistenceDebugFlags; 042import com.echothree.util.server.persistence.Session; 043import java.sql.PreparedStatement; 044import java.sql.ResultSet; 045import java.sql.SQLException; 046import java.sql.Types; 047import java.io.ByteArrayInputStream; 048import java.io.StringReader; 049import java.util.ArrayList; 050import java.util.Collection; 051import java.util.HashSet; 052import java.util.List; 053import java.util.Map; 054import java.util.Set; 055import javax.enterprise.context.ApplicationScoped; 056import javax.enterprise.inject.spi.CDI; 057import javax.inject.Inject; 058import org.jooq.ResultQuery; 059import org.slf4j.Logger; 060import org.slf4j.LoggerFactory; 061 062@ApplicationScoped 063public class TrainingClassDetailFactory 064 implements BaseFactory<TrainingClassDetailPK, TrainingClassDetail> { 065 066 @Inject 067 Session session; 068 069 //private static final Logger log = LoggerFactory.getLogger(TrainingClassDetailFactory.class); 070 071 final private static String SQL_SELECT_READ_ONLY = "SELECT trnclsdt_trainingclassdetailid, trnclsdt_trncls_trainingclassid, trnclsdt_trainingclassname, trnclsdt_estimatedreadingtime, trnclsdt_readingtimeallowed, trnclsdt_estimatedtestingtime, trnclsdt_testingtimeallowed, trnclsdt_requiredcompletiontime, trnclsdt_wes_workeffortscopeid, trnclsdt_defaultpercentagetopass, trnclsdt_overallquestioncount, trnclsdt_testingvaliditytime, trnclsdt_expiredretentiontime, trnclsdt_alwaysreassignonexpiration, trnclsdt_isdefault, trnclsdt_sortorder, trnclsdt_fromtime, trnclsdt_thrutime FROM trainingclassdetails WHERE trnclsdt_trainingclassdetailid = ?"; 072 final private static String SQL_SELECT_READ_WRITE = "SELECT trnclsdt_trainingclassdetailid, trnclsdt_trncls_trainingclassid, trnclsdt_trainingclassname, trnclsdt_estimatedreadingtime, trnclsdt_readingtimeallowed, trnclsdt_estimatedtestingtime, trnclsdt_testingtimeallowed, trnclsdt_requiredcompletiontime, trnclsdt_wes_workeffortscopeid, trnclsdt_defaultpercentagetopass, trnclsdt_overallquestioncount, trnclsdt_testingvaliditytime, trnclsdt_expiredretentiontime, trnclsdt_alwaysreassignonexpiration, trnclsdt_isdefault, trnclsdt_sortorder, trnclsdt_fromtime, trnclsdt_thrutime FROM trainingclassdetails WHERE trnclsdt_trainingclassdetailid = ? FOR UPDATE"; 073 final private static String SQL_INSERT = "INSERT INTO trainingclassdetails (trnclsdt_trainingclassdetailid, trnclsdt_trncls_trainingclassid, trnclsdt_trainingclassname, trnclsdt_estimatedreadingtime, trnclsdt_readingtimeallowed, trnclsdt_estimatedtestingtime, trnclsdt_testingtimeallowed, trnclsdt_requiredcompletiontime, trnclsdt_wes_workeffortscopeid, trnclsdt_defaultpercentagetopass, trnclsdt_overallquestioncount, trnclsdt_testingvaliditytime, trnclsdt_expiredretentiontime, trnclsdt_alwaysreassignonexpiration, trnclsdt_isdefault, trnclsdt_sortorder, trnclsdt_fromtime, trnclsdt_thrutime) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; 074 final private static String SQL_UPDATE = "UPDATE trainingclassdetails SET trnclsdt_trncls_trainingclassid = ?, trnclsdt_trainingclassname = ?, trnclsdt_estimatedreadingtime = ?, trnclsdt_readingtimeallowed = ?, trnclsdt_estimatedtestingtime = ?, trnclsdt_testingtimeallowed = ?, trnclsdt_requiredcompletiontime = ?, trnclsdt_wes_workeffortscopeid = ?, trnclsdt_defaultpercentagetopass = ?, trnclsdt_overallquestioncount = ?, trnclsdt_testingvaliditytime = ?, trnclsdt_expiredretentiontime = ?, trnclsdt_alwaysreassignonexpiration = ?, trnclsdt_isdefault = ?, trnclsdt_sortorder = ?, trnclsdt_fromtime = ?, trnclsdt_thrutime = ? WHERE trnclsdt_trainingclassdetailid = ?"; 075 final private static String SQL_DELETE = "DELETE FROM trainingclassdetails WHERE trnclsdt_trainingclassdetailid = ?"; 076 final private static String SQL_VALID = "SELECT COUNT(*) FROM trainingclassdetails WHERE trnclsdt_trainingclassdetailid = ?"; 077 078 final private static String PK_COLUMN = "trnclsdt_trainingclassdetailid"; 079 final private static String ALL_COLUMNS = "trnclsdt_trainingclassdetailid, trnclsdt_trncls_trainingclassid, trnclsdt_trainingclassname, trnclsdt_estimatedreadingtime, trnclsdt_readingtimeallowed, trnclsdt_estimatedtestingtime, trnclsdt_testingtimeallowed, trnclsdt_requiredcompletiontime, trnclsdt_wes_workeffortscopeid, trnclsdt_defaultpercentagetopass, trnclsdt_overallquestioncount, trnclsdt_testingvaliditytime, trnclsdt_expiredretentiontime, trnclsdt_alwaysreassignonexpiration, trnclsdt_isdefault, trnclsdt_sortorder, trnclsdt_fromtime, trnclsdt_thrutime"; 080 final public static String TABLE_NAME = "trainingclassdetails"; 081 082 final public static String TRNCLSDT_TRAININGCLASSDETAILID = "trnclsdt_trainingclassdetailid"; 083 final public static String TRNCLSDT_TRNCLS_TRAININGCLASSID = "trnclsdt_trncls_trainingclassid"; 084 final public static String TRNCLSDT_TRAININGCLASSNAME = "trnclsdt_trainingclassname"; 085 final public static String TRNCLSDT_ESTIMATEDREADINGTIME = "trnclsdt_estimatedreadingtime"; 086 final public static String TRNCLSDT_READINGTIMEALLOWED = "trnclsdt_readingtimeallowed"; 087 final public static String TRNCLSDT_ESTIMATEDTESTINGTIME = "trnclsdt_estimatedtestingtime"; 088 final public static String TRNCLSDT_TESTINGTIMEALLOWED = "trnclsdt_testingtimeallowed"; 089 final public static String TRNCLSDT_REQUIREDCOMPLETIONTIME = "trnclsdt_requiredcompletiontime"; 090 final public static String TRNCLSDT_WES_WORKEFFORTSCOPEID = "trnclsdt_wes_workeffortscopeid"; 091 final public static String TRNCLSDT_DEFAULTPERCENTAGETOPASS = "trnclsdt_defaultpercentagetopass"; 092 final public static String TRNCLSDT_OVERALLQUESTIONCOUNT = "trnclsdt_overallquestioncount"; 093 final public static String TRNCLSDT_TESTINGVALIDITYTIME = "trnclsdt_testingvaliditytime"; 094 final public static String TRNCLSDT_EXPIREDRETENTIONTIME = "trnclsdt_expiredretentiontime"; 095 final public static String TRNCLSDT_ALWAYSREASSIGNONEXPIRATION = "trnclsdt_alwaysreassignonexpiration"; 096 final public static String TRNCLSDT_ISDEFAULT = "trnclsdt_isdefault"; 097 final public static String TRNCLSDT_SORTORDER = "trnclsdt_sortorder"; 098 final public static String TRNCLSDT_FROMTIME = "trnclsdt_fromtime"; 099 final public static String TRNCLSDT_THRUTIME = "trnclsdt_thrutime"; 100 101 final private static EntityIdGenerator entityIdGenerator = new EntityIdGenerator(TrainingClassDetailConstants.COMPONENT_VENDOR_NAME, TrainingClassDetailConstants.ENTITY_TYPE_NAME); 102 103 /** Creates a new instance of TrainingClassDetailFactory */ 104 protected TrainingClassDetailFactory() { 105 super(); 106 } 107 108 public static TrainingClassDetailFactory getInstance() { 109 return CDI.current().select(TrainingClassDetailFactory.class).get(); 110 } 111 112 @Override 113 public String getPKColumn() { 114 return PK_COLUMN; 115 } 116 117 @Override 118 public String getAllColumns() { 119 return ALL_COLUMNS; 120 } 121 122 @Override 123 public String getTableName() { 124 return TABLE_NAME; 125 } 126 127 @Override 128 public String getComponentVendorName() { 129 return TrainingClassDetailConstants.COMPONENT_VENDOR_NAME; 130 } 131 132 @Override 133 public String getEntityTypeName() { 134 return TrainingClassDetailConstants.ENTITY_TYPE_NAME; 135 } 136 137 public PreparedStatement prepareStatement(String query) { 138 return session.prepareStatement(TrainingClassDetailFactory.class, query); 139 } 140 141 public TrainingClassDetailPK getNextPK() { 142 return new TrainingClassDetailPK(entityIdGenerator.getNextEntityId()); 143 } 144 145 public Set<TrainingClassDetailPK> getPKsFromResultSetAsSet(ResultSet rs) 146 throws PersistenceDatabaseException { 147 Set<TrainingClassDetailPK> _result = new HashSet<>(); 148 149 try { 150 while(rs.next()) { 151 _result.add(getPKFromResultSet(rs)); 152 } 153 } catch (SQLException se) { 154 throw new PersistenceDatabaseException(se); 155 } 156 157 return _result; 158 } 159 160 public java.util.List<TrainingClassDetailPK> getPKsFromResultSetAsList(ResultSet rs) 161 throws PersistenceDatabaseException { 162 java.util.List<TrainingClassDetailPK> _result = new ArrayList<>(); 163 164 try { 165 while(rs.next()) { 166 _result.add(getPKFromResultSet(rs)); 167 } 168 } catch (SQLException se) { 169 throw new PersistenceDatabaseException(se); 170 } 171 172 return _result; 173 } 174 175 public TrainingClassDetailPK getPKFromResultSet(ResultSet rs) 176 throws PersistenceDatabaseException { 177 TrainingClassDetailPK _result; 178 179 try { 180 long trnclsdt_trainingclassdetailid = rs.getLong(TRNCLSDT_TRAININGCLASSDETAILID); 181 Long _entityId = rs.wasNull() ? null : trnclsdt_trainingclassdetailid; 182 183 _result = new TrainingClassDetailPK(_entityId); 184 } catch (SQLException se) { 185 throw new PersistenceDatabaseException(se); 186 } 187 188 return _result; 189 } 190 191 public java.util.List<TrainingClassDetailValue> getValuesFromPKs(Collection<TrainingClassDetailPK> pks) 192 throws PersistenceDatabaseException { 193 java.util.List<TrainingClassDetailValue> _values = new ArrayList<>(pks.size()); 194 195 for(TrainingClassDetailPK _pk: pks) { 196 _values.add(getValueFromPK(_pk)); 197 } 198 199 return _values; 200 } 201 202 public TrainingClassDetailValue getValueFromPK(TrainingClassDetailPK pk) 203 throws PersistenceDatabaseException { 204 TrainingClassDetailValue _value; 205 206 // See if we already have the entity in the session cache 207 TrainingClassDetail _entity = (TrainingClassDetail)session.getEntity(pk); 208 if(_entity == null) 209 _value = getEntityFromPK(EntityPermission.READ_ONLY, pk).getTrainingClassDetailValue(); 210 else 211 _value = _entity.getTrainingClassDetailValue(); 212 213 return _value; 214 } 215 216 public java.util.List<TrainingClassDetailValue> getValuesFromResultSet(ResultSet rs) 217 throws PersistenceDatabaseException { 218 java.util.List<TrainingClassDetailValue> _result = new ArrayList<>(); 219 220 try { 221 while(rs.next()) { 222 _result.add(getValueFromResultSet(rs)); 223 } 224 } catch (SQLException se) { 225 throw new PersistenceDatabaseException(se); 226 } 227 228 return _result; 229 } 230 231 public TrainingClassDetailValue getValueFromResultSet(ResultSet rs) 232 throws PersistenceDatabaseException { 233 TrainingClassDetailValue _value; 234 235 try { 236 Long trnclsdt_trainingclassdetailid = rs.getLong(TRNCLSDT_TRAININGCLASSDETAILID); 237 TrainingClassDetailPK _pk = new TrainingClassDetailPK(trnclsdt_trainingclassdetailid); 238 239 // See if we already have the entity in the session cache 240 TrainingClassDetail _entity = (TrainingClassDetail)session.getEntity(_pk); 241 242 if(_entity == null) { 243 Long trnclsdt_trncls_trainingclassid = rs.getLong(TRNCLSDT_TRNCLS_TRAININGCLASSID); 244 if(rs.wasNull()) 245 trnclsdt_trncls_trainingclassid = null; 246 247 String trnclsdt_trainingclassname = rs.getString(TRNCLSDT_TRAININGCLASSNAME); 248 if(rs.wasNull()) 249 trnclsdt_trainingclassname = null; 250 251 Long trnclsdt_estimatedreadingtime = rs.getLong(TRNCLSDT_ESTIMATEDREADINGTIME); 252 if(rs.wasNull()) 253 trnclsdt_estimatedreadingtime = null; 254 255 Long trnclsdt_readingtimeallowed = rs.getLong(TRNCLSDT_READINGTIMEALLOWED); 256 if(rs.wasNull()) 257 trnclsdt_readingtimeallowed = null; 258 259 Long trnclsdt_estimatedtestingtime = rs.getLong(TRNCLSDT_ESTIMATEDTESTINGTIME); 260 if(rs.wasNull()) 261 trnclsdt_estimatedtestingtime = null; 262 263 Long trnclsdt_testingtimeallowed = rs.getLong(TRNCLSDT_TESTINGTIMEALLOWED); 264 if(rs.wasNull()) 265 trnclsdt_testingtimeallowed = null; 266 267 Long trnclsdt_requiredcompletiontime = rs.getLong(TRNCLSDT_REQUIREDCOMPLETIONTIME); 268 if(rs.wasNull()) 269 trnclsdt_requiredcompletiontime = null; 270 271 Long trnclsdt_wes_workeffortscopeid = rs.getLong(TRNCLSDT_WES_WORKEFFORTSCOPEID); 272 if(rs.wasNull()) 273 trnclsdt_wes_workeffortscopeid = null; 274 275 Integer trnclsdt_defaultpercentagetopass = rs.getInt(TRNCLSDT_DEFAULTPERCENTAGETOPASS); 276 if(rs.wasNull()) 277 trnclsdt_defaultpercentagetopass = null; 278 279 Integer trnclsdt_overallquestioncount = rs.getInt(TRNCLSDT_OVERALLQUESTIONCOUNT); 280 if(rs.wasNull()) 281 trnclsdt_overallquestioncount = null; 282 283 Long trnclsdt_testingvaliditytime = rs.getLong(TRNCLSDT_TESTINGVALIDITYTIME); 284 if(rs.wasNull()) 285 trnclsdt_testingvaliditytime = null; 286 287 Long trnclsdt_expiredretentiontime = rs.getLong(TRNCLSDT_EXPIREDRETENTIONTIME); 288 if(rs.wasNull()) 289 trnclsdt_expiredretentiontime = null; 290 291 Boolean trnclsdt_alwaysreassignonexpiration = rs.getInt(TRNCLSDT_ALWAYSREASSIGNONEXPIRATION) == 1; 292 if(rs.wasNull()) 293 trnclsdt_alwaysreassignonexpiration = null; 294 295 Boolean trnclsdt_isdefault = rs.getInt(TRNCLSDT_ISDEFAULT) == 1; 296 if(rs.wasNull()) 297 trnclsdt_isdefault = null; 298 299 Integer trnclsdt_sortorder = rs.getInt(TRNCLSDT_SORTORDER); 300 if(rs.wasNull()) 301 trnclsdt_sortorder = null; 302 303 Long trnclsdt_fromtime = rs.getLong(TRNCLSDT_FROMTIME); 304 if(rs.wasNull()) 305 trnclsdt_fromtime = null; 306 307 Long trnclsdt_thrutime = rs.getLong(TRNCLSDT_THRUTIME); 308 if(rs.wasNull()) 309 trnclsdt_thrutime = null; 310 311 _value = new TrainingClassDetailValue(_pk, new TrainingClassPK(trnclsdt_trncls_trainingclassid), trnclsdt_trainingclassname, trnclsdt_estimatedreadingtime, trnclsdt_readingtimeallowed, trnclsdt_estimatedtestingtime, trnclsdt_testingtimeallowed, trnclsdt_requiredcompletiontime, new WorkEffortScopePK(trnclsdt_wes_workeffortscopeid), trnclsdt_defaultpercentagetopass, trnclsdt_overallquestioncount, trnclsdt_testingvaliditytime, trnclsdt_expiredretentiontime, trnclsdt_alwaysreassignonexpiration, trnclsdt_isdefault, trnclsdt_sortorder, trnclsdt_fromtime, trnclsdt_thrutime); 312 } else 313 _value = _entity.getTrainingClassDetailValue(); 314 } catch (SQLException se) { 315 throw new PersistenceDatabaseException(se); 316 } 317 318 return _value; 319 } 320 321 public java.util.List<TrainingClassDetail> getEntitiesFromPKs(EntityPermission entityPermission, Collection<TrainingClassDetailPK> pks) 322 throws PersistenceDatabaseException { 323 java.util.List<TrainingClassDetail> _entities = new ArrayList<>(pks.size()); 324 325 for(TrainingClassDetailPK _pk: pks) { 326 _entities.add(getEntityFromPK(entityPermission, _pk)); 327 } 328 329 return _entities; 330 } 331 332 public TrainingClassDetail getEntityFromValue(EntityPermission entityPermission, TrainingClassDetailValue value) { 333 return getEntityFromPK(entityPermission, value.getPrimaryKey()); 334 } 335 336 public TrainingClassDetail getEntityFromCache(TrainingClassDetailPK pk) { 337 TrainingClassDetailValue _value = (TrainingClassDetailValue)session.getValueCache().get(pk); 338 339 return _value == null ? null : new TrainingClassDetail(_value, EntityPermission.READ_ONLY); 340 } 341 342 public TrainingClassDetail getEntityFromPK(EntityPermission entityPermission, TrainingClassDetailPK pk) 343 throws PersistenceDatabaseException { 344 TrainingClassDetail _entity; 345 346 // See if we already have the entity in the session cache 347 _entity = (TrainingClassDetail)session.getEntity(pk); 348 if(_entity != null) { 349 // If the requested permission is READ_WRITE, and the cached permission is 350 // READ_ONLY, then pretend that the cached object wasn't found, and create 351 // a new entity that is READ_WRITE. 352 if(entityPermission.equals(EntityPermission.READ_WRITE)) { 353 if(_entity.getEntityPermission().equals(EntityPermission.READ_ONLY)) 354 _entity = null; 355 } 356 } 357 358 if(_entity == null && entityPermission.equals(EntityPermission.READ_ONLY)) { 359 _entity = getEntityFromCache(pk); 360 } 361 362 if(_entity == null) { 363 PreparedStatement _ps = session.prepareStatement(entityPermission.equals(EntityPermission.READ_ONLY)? SQL_SELECT_READ_ONLY: SQL_SELECT_READ_WRITE); 364 long _entityId = pk.getEntityId(); 365 ResultSet _rs = null; 366 367 try { 368 _ps.setLong(1, _entityId); 369 _rs = _ps.executeQuery(); 370 if(_rs.next()) { 371 _entity = getEntityFromResultSet(entityPermission, _rs); 372 } 373 } catch (SQLException se) { 374 throw new PersistenceDatabaseException(se); 375 } finally { 376 if(_rs != null) { 377 try { 378 _rs.close(); 379 } catch (SQLException se) { 380 // do nothing 381 } 382 } 383 } 384 } 385 386 return _entity; 387 } 388 389 public Set<TrainingClassDetailPK> getPKsFromQueryAsSet(PreparedStatement ps, final Object... params) 390 throws PersistenceDatabaseException { 391 Set<TrainingClassDetailPK> _pks; 392 ResultSet _rs = null; 393 394 try { 395 if(params.length != 0) { 396 Session.setQueryParams(ps, params); 397 } 398 399 _rs = ps.executeQuery(); 400 _pks = getPKsFromResultSetAsSet(_rs); 401 _rs.close(); 402 } catch (SQLException se) { 403 throw new PersistenceDatabaseException(se); 404 } finally { 405 if(_rs != null) { 406 try { 407 _rs.close(); 408 } catch (SQLException se) { 409 // do nothing 410 } 411 } 412 } 413 414 return _pks; 415 } 416 417 public java.util.List<TrainingClassDetailPK> getPKsFromQueryAsList(PreparedStatement ps, final Object... params) 418 throws PersistenceDatabaseException { 419 java.util.List<TrainingClassDetailPK> _pks; 420 ResultSet _rs = null; 421 422 try { 423 if(params.length != 0) { 424 Session.setQueryParams(ps, params); 425 } 426 427 _rs = ps.executeQuery(); 428 _pks = getPKsFromResultSetAsList(_rs); 429 _rs.close(); 430 } catch (SQLException se) { 431 throw new PersistenceDatabaseException(se); 432 } finally { 433 if(_rs != null) { 434 try { 435 _rs.close(); 436 } catch (SQLException se) { 437 // do nothing 438 } 439 } 440 } 441 442 return _pks; 443 } 444 445 public TrainingClassDetailPK getPKFromQuery(PreparedStatement ps, final Object... params) 446 throws PersistenceDatabaseException { 447 TrainingClassDetailPK _pk = null; 448 ResultSet _rs = null; 449 450 try { 451 if(params.length != 0) { 452 Session.setQueryParams(ps, params); 453 } 454 455 _rs = ps.executeQuery(); 456 if(_rs.next()) { 457 _pk = getPKFromResultSet(_rs); 458 } 459 _rs.close(); 460 } catch (SQLException se) { 461 throw new PersistenceDatabaseException(se); 462 } finally { 463 if(_rs != null) { 464 try { 465 _rs.close(); 466 } catch (SQLException se) { 467 // do nothing 468 } 469 } 470 } 471 472 return _pk; 473 } 474 475 public java.util.List<TrainingClassDetail> getEntitiesFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap, final Object... params) 476 throws PersistenceDatabaseException { 477 PreparedStatement ps = session.prepareStatement(TrainingClassDetailFactory.class, queryMap.get(entityPermission)); 478 479 return getEntitiesFromQuery(entityPermission, ps, params); 480 } 481 482 public java.util.List<TrainingClassDetail> getEntitiesFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap) 483 throws PersistenceDatabaseException { 484 PreparedStatement ps = session.prepareStatement(TrainingClassDetailFactory.class, queryMap.get(entityPermission)); 485 486 return getEntitiesFromQuery(entityPermission, ps); 487 } 488 489 public java.util.List<TrainingClassDetail> getEntitiesFromQuery(EntityPermission entityPermission, ResultQuery<?> query) 490 throws PersistenceDatabaseException { 491 PreparedStatement ps = session.prepareStatement(TrainingClassDetailFactory.class, query.getSQL()); 492 493 return getEntitiesFromQuery(entityPermission, ps, query.getBindValues().toArray()); 494 } 495 496 public java.util.List<TrainingClassDetail> getEntitiesFromQuery(EntityPermission entityPermission, PreparedStatement ps, final Object... params) 497 throws PersistenceDatabaseException { 498 java.util.List<TrainingClassDetail> _entities; 499 ResultSet _rs = null; 500 501 try { 502 if(params.length != 0) { 503 Session.setQueryParams(ps, params); 504 } 505 506 _rs = ps.executeQuery(); 507 _entities = getEntitiesFromResultSet(entityPermission, _rs); 508 _rs.close(); 509 } catch (SQLException se) { 510 throw new PersistenceDatabaseException(se); 511 } finally { 512 if(_rs != null) { 513 try { 514 _rs.close(); 515 } catch (SQLException se) { 516 // do nothing 517 } 518 } 519 } 520 521 return _entities; 522 } 523 524 public TrainingClassDetail getEntityFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap, final Object... params) 525 throws PersistenceDatabaseException { 526 PreparedStatement ps = session.prepareStatement(TrainingClassDetailFactory.class, queryMap.get(entityPermission)); 527 528 return getEntityFromQuery(entityPermission, ps, params); 529 } 530 531 public TrainingClassDetail getEntityFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap) 532 throws PersistenceDatabaseException { 533 PreparedStatement ps = session.prepareStatement(TrainingClassDetailFactory.class, queryMap.get(entityPermission)); 534 535 return getEntityFromQuery(entityPermission, ps); 536 } 537 538 public TrainingClassDetail getEntityFromQuery(EntityPermission entityPermission, ResultQuery<?> query) 539 throws PersistenceDatabaseException { 540 PreparedStatement ps = session.prepareStatement(TrainingClassDetailFactory.class, query.getSQL()); 541 542 return getEntityFromQuery(entityPermission, ps, query.getBindValues().toArray()); 543 } 544 545 public TrainingClassDetail getEntityFromQuery(EntityPermission entityPermission, PreparedStatement ps, final Object... params) 546 throws PersistenceDatabaseException { 547 TrainingClassDetail _entity = null; 548 ResultSet _rs = null; 549 550 try { 551 if(params.length != 0) { 552 Session.setQueryParams(ps, params); 553 } 554 555 _rs = ps.executeQuery(); 556 if(_rs.next()) { 557 _entity = getEntityFromResultSet(entityPermission, _rs); 558 } 559 _rs.close(); 560 } catch (SQLException se) { 561 throw new PersistenceDatabaseException(se); 562 } finally { 563 if(_rs != null) { 564 try { 565 _rs.close(); 566 } catch (SQLException se) { 567 // do nothing 568 } 569 } 570 } 571 572 return _entity; 573 } 574 575 public java.util.List<TrainingClassDetail> getEntitiesFromResultSet(EntityPermission entityPermission, ResultSet rs) 576 throws PersistenceDatabaseException { 577 java.util.List<TrainingClassDetail> _result = new ArrayList<>(); 578 579 try { 580 while(rs.next()) { 581 _result.add(getEntityFromResultSet(entityPermission, rs)); 582 } 583 } catch (SQLException se) { 584 throw new PersistenceDatabaseException(se); 585 } 586 587 return _result; 588 } 589 590 public TrainingClassDetail getEntityFromResultSet(EntityPermission entityPermission, ResultSet rs) 591 throws PersistenceDatabaseException { 592 TrainingClassDetail _entity; 593 594 try { 595 Long trnclsdt_trainingclassdetailid = rs.getLong(TRNCLSDT_TRAININGCLASSDETAILID); 596 TrainingClassDetailPK _pk = new TrainingClassDetailPK(trnclsdt_trainingclassdetailid); 597 598 // See if we already have the entity in the session cache 599 _entity = (TrainingClassDetail)session.getEntity(_pk); 600 if(_entity != null) { 601 // If the requested permission is READ_WRITE, and the cached permission is 602 // READ_ONLY, then pretend that the cached object wasn't found, and create 603 // a new entity that is READ_WRITE. 604 if(entityPermission.equals(EntityPermission.READ_WRITE)) { 605 if(_entity.getEntityPermission().equals(EntityPermission.READ_ONLY)) 606 _entity = null; 607 } 608 } 609 boolean foundInSessionCache = _entity != null; 610 611 if(_entity == null && entityPermission.equals(EntityPermission.READ_ONLY)) { 612 _entity = getEntityFromCache(_pk); 613 } 614 615 if(_entity == null) { 616 Long trnclsdt_trncls_trainingclassid = rs.getLong(TRNCLSDT_TRNCLS_TRAININGCLASSID); 617 if(rs.wasNull()) 618 trnclsdt_trncls_trainingclassid = null; 619 620 String trnclsdt_trainingclassname = rs.getString(TRNCLSDT_TRAININGCLASSNAME); 621 if(rs.wasNull()) 622 trnclsdt_trainingclassname = null; 623 624 Long trnclsdt_estimatedreadingtime = rs.getLong(TRNCLSDT_ESTIMATEDREADINGTIME); 625 if(rs.wasNull()) 626 trnclsdt_estimatedreadingtime = null; 627 628 Long trnclsdt_readingtimeallowed = rs.getLong(TRNCLSDT_READINGTIMEALLOWED); 629 if(rs.wasNull()) 630 trnclsdt_readingtimeallowed = null; 631 632 Long trnclsdt_estimatedtestingtime = rs.getLong(TRNCLSDT_ESTIMATEDTESTINGTIME); 633 if(rs.wasNull()) 634 trnclsdt_estimatedtestingtime = null; 635 636 Long trnclsdt_testingtimeallowed = rs.getLong(TRNCLSDT_TESTINGTIMEALLOWED); 637 if(rs.wasNull()) 638 trnclsdt_testingtimeallowed = null; 639 640 Long trnclsdt_requiredcompletiontime = rs.getLong(TRNCLSDT_REQUIREDCOMPLETIONTIME); 641 if(rs.wasNull()) 642 trnclsdt_requiredcompletiontime = null; 643 644 Long trnclsdt_wes_workeffortscopeid = rs.getLong(TRNCLSDT_WES_WORKEFFORTSCOPEID); 645 if(rs.wasNull()) 646 trnclsdt_wes_workeffortscopeid = null; 647 648 Integer trnclsdt_defaultpercentagetopass = rs.getInt(TRNCLSDT_DEFAULTPERCENTAGETOPASS); 649 if(rs.wasNull()) 650 trnclsdt_defaultpercentagetopass = null; 651 652 Integer trnclsdt_overallquestioncount = rs.getInt(TRNCLSDT_OVERALLQUESTIONCOUNT); 653 if(rs.wasNull()) 654 trnclsdt_overallquestioncount = null; 655 656 Long trnclsdt_testingvaliditytime = rs.getLong(TRNCLSDT_TESTINGVALIDITYTIME); 657 if(rs.wasNull()) 658 trnclsdt_testingvaliditytime = null; 659 660 Long trnclsdt_expiredretentiontime = rs.getLong(TRNCLSDT_EXPIREDRETENTIONTIME); 661 if(rs.wasNull()) 662 trnclsdt_expiredretentiontime = null; 663 664 Boolean trnclsdt_alwaysreassignonexpiration = rs.getInt(TRNCLSDT_ALWAYSREASSIGNONEXPIRATION) == 1; 665 if(rs.wasNull()) 666 trnclsdt_alwaysreassignonexpiration = null; 667 668 Boolean trnclsdt_isdefault = rs.getInt(TRNCLSDT_ISDEFAULT) == 1; 669 if(rs.wasNull()) 670 trnclsdt_isdefault = null; 671 672 Integer trnclsdt_sortorder = rs.getInt(TRNCLSDT_SORTORDER); 673 if(rs.wasNull()) 674 trnclsdt_sortorder = null; 675 676 Long trnclsdt_fromtime = rs.getLong(TRNCLSDT_FROMTIME); 677 if(rs.wasNull()) 678 trnclsdt_fromtime = null; 679 680 Long trnclsdt_thrutime = rs.getLong(TRNCLSDT_THRUTIME); 681 if(rs.wasNull()) 682 trnclsdt_thrutime = null; 683 684 TrainingClassDetailValue _value = new TrainingClassDetailValue(_pk, trnclsdt_trncls_trainingclassid == null? null: new TrainingClassPK(trnclsdt_trncls_trainingclassid), trnclsdt_trainingclassname, trnclsdt_estimatedreadingtime, trnclsdt_readingtimeallowed, trnclsdt_estimatedtestingtime, trnclsdt_testingtimeallowed, trnclsdt_requiredcompletiontime, trnclsdt_wes_workeffortscopeid == null? null: new WorkEffortScopePK(trnclsdt_wes_workeffortscopeid), trnclsdt_defaultpercentagetopass, trnclsdt_overallquestioncount, trnclsdt_testingvaliditytime, trnclsdt_expiredretentiontime, trnclsdt_alwaysreassignonexpiration, trnclsdt_isdefault, trnclsdt_sortorder, trnclsdt_fromtime, trnclsdt_thrutime); 685 _entity = new TrainingClassDetail(_value, entityPermission); 686 } 687 688 if(!foundInSessionCache) { 689 if(entityPermission.equals(EntityPermission.READ_ONLY)) { 690 session.putReadOnlyEntity(_pk, _entity); 691 session.getValueCache().put(_entity.getTrainingClassDetailValue()); 692 } else { 693 session.putReadWriteEntity(_pk, _entity); 694 } 695 } 696 } catch (SQLException se) { 697 throw new PersistenceDatabaseException(se); 698 } 699 700 return _entity; 701 } 702 703 public TrainingClassDetail create(TrainingClass trainingClass, String trainingClassName, Long estimatedReadingTime, Long readingTimeAllowed, Long estimatedTestingTime, Long testingTimeAllowed, Long requiredCompletionTime, WorkEffortScope workEffortScope, Integer defaultPercentageToPass, Integer overallQuestionCount, Long testingValidityTime, Long expiredRetentionTime, Boolean alwaysReassignOnExpiration, Boolean isDefault, Integer sortOrder, Long fromTime, Long thruTime) 704 throws PersistenceDatabaseException, PersistenceNotNullException { 705 return create(trainingClass == null ? null : trainingClass.getPrimaryKey(), trainingClassName, estimatedReadingTime, readingTimeAllowed, estimatedTestingTime, testingTimeAllowed, requiredCompletionTime, workEffortScope == null ? null : workEffortScope.getPrimaryKey(), defaultPercentageToPass, overallQuestionCount, testingValidityTime, expiredRetentionTime, alwaysReassignOnExpiration, isDefault, sortOrder, fromTime, thruTime); 706 } 707 708 private void bindForCreate(PreparedStatement _ps, TrainingClassDetailValue _value) 709 throws SQLException { 710 _ps.setLong(1, _value.getEntityId()); 711 712 TrainingClassPK trnclsdt_trncls_trainingclassid = _value.getTrainingClassPK(); 713 if(trnclsdt_trncls_trainingclassid == null) 714 _ps.setNull(2, Types.BIGINT); 715 else 716 _ps.setLong(2, trnclsdt_trncls_trainingclassid.getEntityId()); 717 718 String trnclsdt_trainingclassname = _value.getTrainingClassName(); 719 if(trnclsdt_trainingclassname == null) 720 _ps.setNull(3, Types.VARCHAR); 721 else 722 _ps.setString(3, trnclsdt_trainingclassname); 723 724 Long trnclsdt_estimatedreadingtime = _value.getEstimatedReadingTime(); 725 if(trnclsdt_estimatedreadingtime == null) 726 _ps.setNull(4, Types.BIGINT); 727 else 728 _ps.setLong(4, trnclsdt_estimatedreadingtime); 729 730 Long trnclsdt_readingtimeallowed = _value.getReadingTimeAllowed(); 731 if(trnclsdt_readingtimeallowed == null) 732 _ps.setNull(5, Types.BIGINT); 733 else 734 _ps.setLong(5, trnclsdt_readingtimeallowed); 735 736 Long trnclsdt_estimatedtestingtime = _value.getEstimatedTestingTime(); 737 if(trnclsdt_estimatedtestingtime == null) 738 _ps.setNull(6, Types.BIGINT); 739 else 740 _ps.setLong(6, trnclsdt_estimatedtestingtime); 741 742 Long trnclsdt_testingtimeallowed = _value.getTestingTimeAllowed(); 743 if(trnclsdt_testingtimeallowed == null) 744 _ps.setNull(7, Types.BIGINT); 745 else 746 _ps.setLong(7, trnclsdt_testingtimeallowed); 747 748 Long trnclsdt_requiredcompletiontime = _value.getRequiredCompletionTime(); 749 if(trnclsdt_requiredcompletiontime == null) 750 _ps.setNull(8, Types.BIGINT); 751 else 752 _ps.setLong(8, trnclsdt_requiredcompletiontime); 753 754 WorkEffortScopePK trnclsdt_wes_workeffortscopeid = _value.getWorkEffortScopePK(); 755 if(trnclsdt_wes_workeffortscopeid == null) 756 _ps.setNull(9, Types.BIGINT); 757 else 758 _ps.setLong(9, trnclsdt_wes_workeffortscopeid.getEntityId()); 759 760 Integer trnclsdt_defaultpercentagetopass = _value.getDefaultPercentageToPass(); 761 if(trnclsdt_defaultpercentagetopass == null) 762 _ps.setNull(10, Types.INTEGER); 763 else 764 _ps.setInt(10, trnclsdt_defaultpercentagetopass); 765 766 Integer trnclsdt_overallquestioncount = _value.getOverallQuestionCount(); 767 if(trnclsdt_overallquestioncount == null) 768 _ps.setNull(11, Types.INTEGER); 769 else 770 _ps.setInt(11, trnclsdt_overallquestioncount); 771 772 Long trnclsdt_testingvaliditytime = _value.getTestingValidityTime(); 773 if(trnclsdt_testingvaliditytime == null) 774 _ps.setNull(12, Types.BIGINT); 775 else 776 _ps.setLong(12, trnclsdt_testingvaliditytime); 777 778 Long trnclsdt_expiredretentiontime = _value.getExpiredRetentionTime(); 779 if(trnclsdt_expiredretentiontime == null) 780 _ps.setNull(13, Types.BIGINT); 781 else 782 _ps.setLong(13, trnclsdt_expiredretentiontime); 783 784 Boolean trnclsdt_alwaysreassignonexpiration = _value.getAlwaysReassignOnExpiration(); 785 if(trnclsdt_alwaysreassignonexpiration == null) 786 _ps.setNull(14, Types.BIT); 787 else 788 _ps.setInt(14, trnclsdt_alwaysreassignonexpiration? 1: 0); 789 790 Boolean trnclsdt_isdefault = _value.getIsDefault(); 791 if(trnclsdt_isdefault == null) 792 _ps.setNull(15, Types.BIT); 793 else 794 _ps.setInt(15, trnclsdt_isdefault? 1: 0); 795 796 Integer trnclsdt_sortorder = _value.getSortOrder(); 797 if(trnclsdt_sortorder == null) 798 _ps.setNull(16, Types.INTEGER); 799 else 800 _ps.setInt(16, trnclsdt_sortorder); 801 802 Long trnclsdt_fromtime = _value.getFromTime(); 803 if(trnclsdt_fromtime == null) 804 _ps.setNull(17, Types.BIGINT); 805 else 806 _ps.setLong(17, trnclsdt_fromtime); 807 808 Long trnclsdt_thrutime = _value.getThruTime(); 809 if(trnclsdt_thrutime == null) 810 _ps.setNull(18, Types.BIGINT); 811 else 812 _ps.setLong(18, trnclsdt_thrutime); 813 814 } 815 816 public TrainingClassDetail create(TrainingClassPK trainingClassPK, String trainingClassName, Long estimatedReadingTime, Long readingTimeAllowed, Long estimatedTestingTime, Long testingTimeAllowed, Long requiredCompletionTime, WorkEffortScopePK workEffortScopePK, Integer defaultPercentageToPass, Integer overallQuestionCount, Long testingValidityTime, Long expiredRetentionTime, Boolean alwaysReassignOnExpiration, Boolean isDefault, Integer sortOrder, Long fromTime, Long thruTime) 817 throws PersistenceDatabaseException, PersistenceNotNullException { 818 TrainingClassDetailPK _pk = getNextPK(); 819 TrainingClassDetailValue _value = new TrainingClassDetailValue(_pk, trainingClassPK, trainingClassName, estimatedReadingTime, readingTimeAllowed, estimatedTestingTime, testingTimeAllowed, requiredCompletionTime, workEffortScopePK, defaultPercentageToPass, overallQuestionCount, testingValidityTime, expiredRetentionTime, alwaysReassignOnExpiration, isDefault, sortOrder, fromTime, thruTime); 820 821 PreparedStatement _ps = session.prepareStatement(SQL_INSERT); 822 823 try { 824 bindForCreate(_ps, _value); 825 826 if(PersistenceDebugFlags.CheckEntityInsertRowCount) { 827 int _count = _ps.executeUpdate(); 828 829 if(_count != 1) { 830 throw new PersistenceDatabaseUpdateException("insert failed, _count = " + _count); 831 } 832 } else { 833 _ps.executeUpdate(); 834 } 835 836 session.getValueCache().put(_value); 837 } catch (SQLException se) { 838 throw new PersistenceDatabaseException(se); 839 } 840 841 TrainingClassDetail _entity = new TrainingClassDetail(_value, EntityPermission.READ_ONLY); 842 session.putReadOnlyEntity(_pk, _entity); 843 844 return _entity; 845 } 846 847 public void create(Collection<TrainingClassDetailValue> _values) 848 throws PersistenceDatabaseException, PersistenceNotNullException { 849 int _size = _values.size(); 850 851 if(_size > 0) { 852 PreparedStatement _ps = session.prepareStatement(SQL_INSERT); 853 List<TrainingClassDetailValue> _cacheValues = new ArrayList<>(_size); 854 855 try { 856 for(TrainingClassDetailValue _value : _values) { 857 _value.setEntityId(entityIdGenerator.getNextEntityId()); 858 bindForCreate(_ps, _value); 859 860 _ps.addBatch(); 861 862 _cacheValues.add(_value); 863 } 864 865 if(PersistenceDebugFlags.CheckEntityInsertRowCount) { 866 int[] _counts = _ps.executeBatch(); 867 868 for(int _countOffset = 0 ; _countOffset < _size ; _countOffset++) { 869 if(_counts[_countOffset] != 1 && _counts[_countOffset] != PreparedStatement.SUCCESS_NO_INFO) { 870 throw new PersistenceDatabaseUpdateException("batch insert failed, _counts[" + _countOffset + "] = " + _counts[_countOffset]); 871 } 872 } 873 } else { 874 _ps.executeBatch(); 875 } 876 877 _ps.clearBatch(); 878 } catch (SQLException se) { 879 throw new PersistenceDatabaseException(se); 880 } 881 882 _cacheValues.forEach((_cacheValue) -> { 883 TrainingClassDetail _cacheEntity = new TrainingClassDetail(_cacheValue, EntityPermission.READ_ONLY); 884 885 session.putReadOnlyEntity(_cacheValue.getPrimaryKey(), _cacheEntity); 886 }); 887 } 888 } 889 890 private boolean bindForStore(PreparedStatement _ps, TrainingClassDetailValue _value) 891 throws SQLException { 892 boolean _hasBeenModified = _value.hasBeenModified(); 893 894 if(_hasBeenModified) { 895 TrainingClassPK trnclsdt_trncls_trainingclassid = _value.getTrainingClassPK(); 896 if(trnclsdt_trncls_trainingclassid == null) 897 _ps.setNull(1, Types.BIGINT); 898 else 899 _ps.setLong(1, trnclsdt_trncls_trainingclassid.getEntityId()); 900 901 String trnclsdt_trainingclassname = _value.getTrainingClassName(); 902 if(trnclsdt_trainingclassname == null) 903 _ps.setNull(2, Types.VARCHAR); 904 else 905 _ps.setString(2, trnclsdt_trainingclassname); 906 907 Long trnclsdt_estimatedreadingtime = _value.getEstimatedReadingTime(); 908 if(trnclsdt_estimatedreadingtime == null) 909 _ps.setNull(3, Types.BIGINT); 910 else 911 _ps.setLong(3, trnclsdt_estimatedreadingtime); 912 913 Long trnclsdt_readingtimeallowed = _value.getReadingTimeAllowed(); 914 if(trnclsdt_readingtimeallowed == null) 915 _ps.setNull(4, Types.BIGINT); 916 else 917 _ps.setLong(4, trnclsdt_readingtimeallowed); 918 919 Long trnclsdt_estimatedtestingtime = _value.getEstimatedTestingTime(); 920 if(trnclsdt_estimatedtestingtime == null) 921 _ps.setNull(5, Types.BIGINT); 922 else 923 _ps.setLong(5, trnclsdt_estimatedtestingtime); 924 925 Long trnclsdt_testingtimeallowed = _value.getTestingTimeAllowed(); 926 if(trnclsdt_testingtimeallowed == null) 927 _ps.setNull(6, Types.BIGINT); 928 else 929 _ps.setLong(6, trnclsdt_testingtimeallowed); 930 931 Long trnclsdt_requiredcompletiontime = _value.getRequiredCompletionTime(); 932 if(trnclsdt_requiredcompletiontime == null) 933 _ps.setNull(7, Types.BIGINT); 934 else 935 _ps.setLong(7, trnclsdt_requiredcompletiontime); 936 937 WorkEffortScopePK trnclsdt_wes_workeffortscopeid = _value.getWorkEffortScopePK(); 938 if(trnclsdt_wes_workeffortscopeid == null) 939 _ps.setNull(8, Types.BIGINT); 940 else 941 _ps.setLong(8, trnclsdt_wes_workeffortscopeid.getEntityId()); 942 943 Integer trnclsdt_defaultpercentagetopass = _value.getDefaultPercentageToPass(); 944 if(trnclsdt_defaultpercentagetopass == null) 945 _ps.setNull(9, Types.INTEGER); 946 else 947 _ps.setInt(9, trnclsdt_defaultpercentagetopass); 948 949 Integer trnclsdt_overallquestioncount = _value.getOverallQuestionCount(); 950 if(trnclsdt_overallquestioncount == null) 951 _ps.setNull(10, Types.INTEGER); 952 else 953 _ps.setInt(10, trnclsdt_overallquestioncount); 954 955 Long trnclsdt_testingvaliditytime = _value.getTestingValidityTime(); 956 if(trnclsdt_testingvaliditytime == null) 957 _ps.setNull(11, Types.BIGINT); 958 else 959 _ps.setLong(11, trnclsdt_testingvaliditytime); 960 961 Long trnclsdt_expiredretentiontime = _value.getExpiredRetentionTime(); 962 if(trnclsdt_expiredretentiontime == null) 963 _ps.setNull(12, Types.BIGINT); 964 else 965 _ps.setLong(12, trnclsdt_expiredretentiontime); 966 967 Boolean trnclsdt_alwaysreassignonexpiration = _value.getAlwaysReassignOnExpiration(); 968 if(trnclsdt_alwaysreassignonexpiration == null) 969 _ps.setNull(13, Types.BIT); 970 else 971 _ps.setInt(13, trnclsdt_alwaysreassignonexpiration? 1: 0); 972 973 Boolean trnclsdt_isdefault = _value.getIsDefault(); 974 if(trnclsdt_isdefault == null) 975 _ps.setNull(14, Types.BIT); 976 else 977 _ps.setInt(14, trnclsdt_isdefault? 1: 0); 978 979 Integer trnclsdt_sortorder = _value.getSortOrder(); 980 if(trnclsdt_sortorder == null) 981 _ps.setNull(15, Types.INTEGER); 982 else 983 _ps.setInt(15, trnclsdt_sortorder); 984 985 Long trnclsdt_fromtime = _value.getFromTime(); 986 if(trnclsdt_fromtime == null) 987 _ps.setNull(16, Types.BIGINT); 988 else 989 _ps.setLong(16, trnclsdt_fromtime); 990 991 Long trnclsdt_thrutime = _value.getThruTime(); 992 if(trnclsdt_thrutime == null) 993 _ps.setNull(17, Types.BIGINT); 994 else 995 _ps.setLong(17, trnclsdt_thrutime); 996 997 _ps.setLong(18, _value.getPrimaryKey().getEntityId()); 998 999 _value.clearHasBeenModified(); 1000 } 1001 1002 return _hasBeenModified; 1003 } 1004 1005 @Override 1006 public void store(TrainingClassDetail entity) 1007 throws PersistenceDatabaseException { 1008 PreparedStatement _ps = session.prepareStatement(SQL_UPDATE); 1009 1010 try { 1011 TrainingClassDetailValue _value = entity.getTrainingClassDetailValue(); 1012 1013 if(bindForStore(_ps, _value)) { 1014 if(PersistenceDebugFlags.CheckEntityUpdateRowCount) { 1015 int _count = _ps.executeUpdate(); 1016 1017 if(_count != 1) { 1018 throw new PersistenceDatabaseUpdateException("update failed, _count = " + _count); 1019 } 1020 } else { 1021 _ps.executeUpdate(); 1022 } 1023 1024 session.getValueCache().put(_value); 1025 } 1026 } catch (SQLException se) { 1027 throw new PersistenceDatabaseException(se); 1028 } 1029 } 1030 1031 @Override 1032 public void store(Collection<TrainingClassDetail> entities) 1033 throws PersistenceDatabaseException { 1034 if(entities.size() > 0) { 1035 PreparedStatement _ps = session.prepareStatement(SQL_UPDATE); 1036 int _modifiedEntities = 0; 1037 1038 try { 1039 for(TrainingClassDetail entity : entities) { 1040 if(bindForStore(_ps, entity.getTrainingClassDetailValue())) { 1041 _ps.addBatch(); 1042 _modifiedEntities++; 1043 } 1044 } 1045 1046 if(_modifiedEntities != 0) { 1047 if(PersistenceDebugFlags.CheckEntityUpdateRowCount) { 1048 int[] _counts = _ps.executeBatch(); 1049 1050 for(int _countOffset = 0 ; _countOffset < _modifiedEntities ; _countOffset++) { 1051 if(_counts[_countOffset] != 1 && _counts[_countOffset] != PreparedStatement.SUCCESS_NO_INFO) { 1052 throw new PersistenceDatabaseUpdateException("batch update failed, _counts[" + _countOffset + "] = " + _counts[_countOffset]); 1053 } 1054 } 1055 } else { 1056 _ps.executeBatch(); 1057 } 1058 1059 _ps.clearBatch(); 1060 1061 entities.forEach((entity) -> { 1062 session.getValueCache().put(entity.getTrainingClassDetailValue()); 1063 }); 1064 } 1065 } catch (SQLException se) { 1066 throw new PersistenceDatabaseException(se); 1067 } 1068 } 1069 } 1070 1071 @Override 1072 public void remove(TrainingClassDetail entity) 1073 throws PersistenceDatabaseException { 1074 remove(entity.getPrimaryKey()); 1075 } 1076 1077 @Override 1078 public void remove(TrainingClassDetailPK pk) 1079 throws PersistenceDatabaseException { 1080 PreparedStatement _ps = session.prepareStatement(SQL_DELETE); 1081 long _entityId = pk.getEntityId(); 1082 1083 try { 1084 _ps.setLong(1, _entityId); 1085 1086 if(PersistenceDebugFlags.CheckEntityDeleteRowCount) { 1087 int _count = _ps.executeUpdate(); 1088 1089 if(_count != 1) { 1090 throw new PersistenceDatabaseUpdateException("remove failed, _count = " + _count); 1091 } 1092 } else { 1093 _ps.executeUpdate(); 1094 } 1095 1096 session.getValueCache().remove(pk); 1097 } catch (SQLException se) { 1098 throw new PersistenceDatabaseException(se); 1099 } 1100 1101 session.removed(pk, false); 1102 } 1103 1104 @Override 1105 public void remove(Collection<TrainingClassDetailPK> pks) 1106 throws PersistenceDatabaseException { 1107 if(pks.size() > 0) { 1108 PreparedStatement _ps = session.prepareStatement(SQL_DELETE); 1109 int _modifiedEntities = 0; 1110 1111 try { 1112 for(TrainingClassDetailPK pk : pks) { 1113 long _entityId = pk.getEntityId(); 1114 1115 _ps.setLong(1, _entityId); 1116 1117 _ps.addBatch(); 1118 _modifiedEntities++; 1119 } 1120 1121 if(_modifiedEntities != 0) { 1122 if(PersistenceDebugFlags.CheckEntityDeleteRowCount) { 1123 int[] _counts = _ps.executeBatch(); 1124 1125 for(int _countOffset = 0 ; _countOffset < _modifiedEntities ; _countOffset++) { 1126 if(_counts[_countOffset] != 1 && _counts[_countOffset] != PreparedStatement.SUCCESS_NO_INFO) { 1127 throw new PersistenceDatabaseUpdateException("batch remove failed, _counts[" + _countOffset + "] = " + _counts[_countOffset]); 1128 } 1129 } 1130 } else { 1131 _ps.executeBatch(); 1132 } 1133 1134 _ps.clearBatch(); 1135 1136 pks.forEach((pk) -> { 1137 session.getValueCache().remove(pk); 1138 }); 1139 } 1140 } catch (SQLException se) { 1141 throw new PersistenceDatabaseException(se); 1142 } 1143 1144 pks.forEach((pk) -> { 1145 session.removed(pk, true); 1146 }); 1147 } 1148 } 1149 1150 @Override 1151 public boolean validPK(TrainingClassDetailPK pk) 1152 throws PersistenceDatabaseException { 1153 boolean valid = false; 1154 PreparedStatement _ps = session.prepareStatement(SQL_VALID); 1155 ResultSet _rs = null; 1156 1157 try { 1158 _ps.setLong(1, pk.getEntityId()); 1159 1160 _rs = _ps.executeQuery(); 1161 if(_rs.next()) { 1162 long _count = _rs.getLong(1); 1163 if(_rs.wasNull()) 1164 _count = 0; 1165 1166 if(_count == 1) 1167 valid = true; 1168 } 1169 } catch (SQLException se) { 1170 throw new PersistenceDatabaseException(se); 1171 } finally { 1172 if(_rs != null) { 1173 try { 1174 _rs.close(); 1175 } catch (SQLException se) { 1176 // do nothing 1177 } 1178 } 1179 } 1180 1181 return valid; 1182 } 1183 1184}