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