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