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