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