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