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