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