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