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