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