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