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 * ItemDetailFactory.java 021 */ 022 023package com.echothree.model.data.item.server.factory; 024 025import com.echothree.model.data.item.common.pk.ItemPK; 026import com.echothree.model.data.item.common.pk.ItemTypePK; 027import com.echothree.model.data.item.common.pk.ItemUseTypePK; 028import com.echothree.model.data.item.common.pk.ItemCategoryPK; 029import com.echothree.model.data.accounting.common.pk.ItemAccountingCategoryPK; 030import com.echothree.model.data.vendor.common.pk.ItemPurchasingCategoryPK; 031import com.echothree.model.data.party.common.pk.PartyPK; 032import com.echothree.model.data.item.common.pk.ItemDeliveryTypePK; 033import com.echothree.model.data.item.common.pk.ItemInventoryTypePK; 034import com.echothree.model.data.sequence.common.pk.SequencePK; 035import com.echothree.model.data.uom.common.pk.UnitOfMeasureKindPK; 036import com.echothree.model.data.item.common.pk.ItemPriceTypePK; 037import com.echothree.model.data.cancellationpolicy.common.pk.CancellationPolicyPK; 038import com.echothree.model.data.returnpolicy.common.pk.ReturnPolicyPK; 039import com.echothree.model.data.style.common.pk.StylePathPK; 040 041import com.echothree.model.data.item.server.entity.Item; 042import com.echothree.model.data.item.server.entity.ItemType; 043import com.echothree.model.data.item.server.entity.ItemUseType; 044import com.echothree.model.data.item.server.entity.ItemCategory; 045import com.echothree.model.data.accounting.server.entity.ItemAccountingCategory; 046import com.echothree.model.data.vendor.server.entity.ItemPurchasingCategory; 047import com.echothree.model.data.party.server.entity.Party; 048import com.echothree.model.data.item.server.entity.ItemDeliveryType; 049import com.echothree.model.data.item.server.entity.ItemInventoryType; 050import com.echothree.model.data.sequence.server.entity.Sequence; 051import com.echothree.model.data.uom.server.entity.UnitOfMeasureKind; 052import com.echothree.model.data.item.server.entity.ItemPriceType; 053import com.echothree.model.data.cancellationpolicy.server.entity.CancellationPolicy; 054import com.echothree.model.data.returnpolicy.server.entity.ReturnPolicy; 055import com.echothree.model.data.style.server.entity.StylePath; 056 057import com.echothree.model.data.item.common.ItemDetailConstants; 058import com.echothree.model.data.item.common.pk.ItemDetailPK; 059import com.echothree.model.data.item.server.value.ItemDetailValue; 060import com.echothree.model.data.item.server.entity.ItemDetail; 061import com.echothree.util.common.exception.PersistenceDatabaseException; 062import com.echothree.util.common.exception.PersistenceDatabaseUpdateException; 063import com.echothree.util.common.exception.PersistenceNotNullException; 064import com.echothree.util.server.persistence.BaseFactory; 065import com.echothree.util.server.persistence.EntityIdGenerator; 066import com.echothree.util.server.persistence.EntityPermission; 067import com.echothree.util.server.persistence.PersistenceDebugFlags; 068import com.echothree.util.server.persistence.Session; 069import com.echothree.util.server.persistence.ThreadSession; 070import java.sql.PreparedStatement; 071import java.sql.ResultSet; 072import java.sql.SQLException; 073import java.sql.Types; 074import java.io.ByteArrayInputStream; 075import java.io.StringReader; 076import java.util.ArrayList; 077import java.util.Collection; 078import java.util.HashSet; 079import java.util.List; 080import java.util.Map; 081import java.util.Set; 082import javax.enterprise.context.ApplicationScoped; 083import javax.enterprise.inject.spi.CDI; 084import org.apache.commons.logging.Log; 085import org.apache.commons.logging.LogFactory; 086 087@ApplicationScoped 088public class ItemDetailFactory 089 implements BaseFactory<ItemDetailPK, ItemDetail> { 090 091 //final private static Log log = LogFactory.getLog(ItemDetailFactory.class); 092 093 final private static String SQL_SELECT_READ_ONLY = "SELECT itmdt_itemdetailid, itmdt_itm_itemid, itmdt_itemname, itmdt_ityp_itemtypeid, itmdt_iutyp_itemusetypeid, itmdt_ic_itemcategoryid, itmdt_iactgc_itemaccountingcategoryid, itmdt_iprchc_itempurchasingcategoryid, itmdt_companypartyid, itmdt_idlvrtyp_itemdeliverytypeid, itmdt_iinvtyp_iteminventorytypeid, itmdt_inventoryserialized, itmdt_serialnumbersequenceid, itmdt_shippingchargeexempt, itmdt_shippingstarttime, itmdt_shippingendtime, itmdt_salesorderstarttime, itmdt_salesorderendtime, itmdt_purchaseorderstarttime, itmdt_purchaseorderendtime, itmdt_allowclubdiscounts, itmdt_allowcoupondiscounts, itmdt_allowassociatepayments, itmdt_uomk_unitofmeasurekindid, itmdt_ipt_itempricetypeid, itmdt_cnclplcy_cancellationpolicyid, itmdt_rtnplcy_returnpolicyid, itmdt_stylpth_stylepathid, itmdt_fromtime, itmdt_thrutime FROM itemdetails WHERE itmdt_itemdetailid = ?"; 094 final private static String SQL_SELECT_READ_WRITE = "SELECT itmdt_itemdetailid, itmdt_itm_itemid, itmdt_itemname, itmdt_ityp_itemtypeid, itmdt_iutyp_itemusetypeid, itmdt_ic_itemcategoryid, itmdt_iactgc_itemaccountingcategoryid, itmdt_iprchc_itempurchasingcategoryid, itmdt_companypartyid, itmdt_idlvrtyp_itemdeliverytypeid, itmdt_iinvtyp_iteminventorytypeid, itmdt_inventoryserialized, itmdt_serialnumbersequenceid, itmdt_shippingchargeexempt, itmdt_shippingstarttime, itmdt_shippingendtime, itmdt_salesorderstarttime, itmdt_salesorderendtime, itmdt_purchaseorderstarttime, itmdt_purchaseorderendtime, itmdt_allowclubdiscounts, itmdt_allowcoupondiscounts, itmdt_allowassociatepayments, itmdt_uomk_unitofmeasurekindid, itmdt_ipt_itempricetypeid, itmdt_cnclplcy_cancellationpolicyid, itmdt_rtnplcy_returnpolicyid, itmdt_stylpth_stylepathid, itmdt_fromtime, itmdt_thrutime FROM itemdetails WHERE itmdt_itemdetailid = ? FOR UPDATE"; 095 final private static String SQL_INSERT = "INSERT INTO itemdetails (itmdt_itemdetailid, itmdt_itm_itemid, itmdt_itemname, itmdt_ityp_itemtypeid, itmdt_iutyp_itemusetypeid, itmdt_ic_itemcategoryid, itmdt_iactgc_itemaccountingcategoryid, itmdt_iprchc_itempurchasingcategoryid, itmdt_companypartyid, itmdt_idlvrtyp_itemdeliverytypeid, itmdt_iinvtyp_iteminventorytypeid, itmdt_inventoryserialized, itmdt_serialnumbersequenceid, itmdt_shippingchargeexempt, itmdt_shippingstarttime, itmdt_shippingendtime, itmdt_salesorderstarttime, itmdt_salesorderendtime, itmdt_purchaseorderstarttime, itmdt_purchaseorderendtime, itmdt_allowclubdiscounts, itmdt_allowcoupondiscounts, itmdt_allowassociatepayments, itmdt_uomk_unitofmeasurekindid, itmdt_ipt_itempricetypeid, itmdt_cnclplcy_cancellationpolicyid, itmdt_rtnplcy_returnpolicyid, itmdt_stylpth_stylepathid, itmdt_fromtime, itmdt_thrutime) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; 096 final private static String SQL_UPDATE = "UPDATE itemdetails SET itmdt_itm_itemid = ?, itmdt_itemname = ?, itmdt_ityp_itemtypeid = ?, itmdt_iutyp_itemusetypeid = ?, itmdt_ic_itemcategoryid = ?, itmdt_iactgc_itemaccountingcategoryid = ?, itmdt_iprchc_itempurchasingcategoryid = ?, itmdt_companypartyid = ?, itmdt_idlvrtyp_itemdeliverytypeid = ?, itmdt_iinvtyp_iteminventorytypeid = ?, itmdt_inventoryserialized = ?, itmdt_serialnumbersequenceid = ?, itmdt_shippingchargeexempt = ?, itmdt_shippingstarttime = ?, itmdt_shippingendtime = ?, itmdt_salesorderstarttime = ?, itmdt_salesorderendtime = ?, itmdt_purchaseorderstarttime = ?, itmdt_purchaseorderendtime = ?, itmdt_allowclubdiscounts = ?, itmdt_allowcoupondiscounts = ?, itmdt_allowassociatepayments = ?, itmdt_uomk_unitofmeasurekindid = ?, itmdt_ipt_itempricetypeid = ?, itmdt_cnclplcy_cancellationpolicyid = ?, itmdt_rtnplcy_returnpolicyid = ?, itmdt_stylpth_stylepathid = ?, itmdt_fromtime = ?, itmdt_thrutime = ? WHERE itmdt_itemdetailid = ?"; 097 final private static String SQL_DELETE = "DELETE FROM itemdetails WHERE itmdt_itemdetailid = ?"; 098 final private static String SQL_VALID = "SELECT COUNT(*) FROM itemdetails WHERE itmdt_itemdetailid = ?"; 099 100 final private static String PK_COLUMN = "itmdt_itemdetailid"; 101 final private static String ALL_COLUMNS = "itmdt_itemdetailid, itmdt_itm_itemid, itmdt_itemname, itmdt_ityp_itemtypeid, itmdt_iutyp_itemusetypeid, itmdt_ic_itemcategoryid, itmdt_iactgc_itemaccountingcategoryid, itmdt_iprchc_itempurchasingcategoryid, itmdt_companypartyid, itmdt_idlvrtyp_itemdeliverytypeid, itmdt_iinvtyp_iteminventorytypeid, itmdt_inventoryserialized, itmdt_serialnumbersequenceid, itmdt_shippingchargeexempt, itmdt_shippingstarttime, itmdt_shippingendtime, itmdt_salesorderstarttime, itmdt_salesorderendtime, itmdt_purchaseorderstarttime, itmdt_purchaseorderendtime, itmdt_allowclubdiscounts, itmdt_allowcoupondiscounts, itmdt_allowassociatepayments, itmdt_uomk_unitofmeasurekindid, itmdt_ipt_itempricetypeid, itmdt_cnclplcy_cancellationpolicyid, itmdt_rtnplcy_returnpolicyid, itmdt_stylpth_stylepathid, itmdt_fromtime, itmdt_thrutime"; 102 final public static String TABLE_NAME = "itemdetails"; 103 104 final public static String ITMDT_ITEMDETAILID = "itmdt_itemdetailid"; 105 final public static String ITMDT_ITM_ITEMID = "itmdt_itm_itemid"; 106 final public static String ITMDT_ITEMNAME = "itmdt_itemname"; 107 final public static String ITMDT_ITYP_ITEMTYPEID = "itmdt_ityp_itemtypeid"; 108 final public static String ITMDT_IUTYP_ITEMUSETYPEID = "itmdt_iutyp_itemusetypeid"; 109 final public static String ITMDT_IC_ITEMCATEGORYID = "itmdt_ic_itemcategoryid"; 110 final public static String ITMDT_IACTGC_ITEMACCOUNTINGCATEGORYID = "itmdt_iactgc_itemaccountingcategoryid"; 111 final public static String ITMDT_IPRCHC_ITEMPURCHASINGCATEGORYID = "itmdt_iprchc_itempurchasingcategoryid"; 112 final public static String ITMDT_COMPANYPARTYID = "itmdt_companypartyid"; 113 final public static String ITMDT_IDLVRTYP_ITEMDELIVERYTYPEID = "itmdt_idlvrtyp_itemdeliverytypeid"; 114 final public static String ITMDT_IINVTYP_ITEMINVENTORYTYPEID = "itmdt_iinvtyp_iteminventorytypeid"; 115 final public static String ITMDT_INVENTORYSERIALIZED = "itmdt_inventoryserialized"; 116 final public static String ITMDT_SERIALNUMBERSEQUENCEID = "itmdt_serialnumbersequenceid"; 117 final public static String ITMDT_SHIPPINGCHARGEEXEMPT = "itmdt_shippingchargeexempt"; 118 final public static String ITMDT_SHIPPINGSTARTTIME = "itmdt_shippingstarttime"; 119 final public static String ITMDT_SHIPPINGENDTIME = "itmdt_shippingendtime"; 120 final public static String ITMDT_SALESORDERSTARTTIME = "itmdt_salesorderstarttime"; 121 final public static String ITMDT_SALESORDERENDTIME = "itmdt_salesorderendtime"; 122 final public static String ITMDT_PURCHASEORDERSTARTTIME = "itmdt_purchaseorderstarttime"; 123 final public static String ITMDT_PURCHASEORDERENDTIME = "itmdt_purchaseorderendtime"; 124 final public static String ITMDT_ALLOWCLUBDISCOUNTS = "itmdt_allowclubdiscounts"; 125 final public static String ITMDT_ALLOWCOUPONDISCOUNTS = "itmdt_allowcoupondiscounts"; 126 final public static String ITMDT_ALLOWASSOCIATEPAYMENTS = "itmdt_allowassociatepayments"; 127 final public static String ITMDT_UOMK_UNITOFMEASUREKINDID = "itmdt_uomk_unitofmeasurekindid"; 128 final public static String ITMDT_IPT_ITEMPRICETYPEID = "itmdt_ipt_itempricetypeid"; 129 final public static String ITMDT_CNCLPLCY_CANCELLATIONPOLICYID = "itmdt_cnclplcy_cancellationpolicyid"; 130 final public static String ITMDT_RTNPLCY_RETURNPOLICYID = "itmdt_rtnplcy_returnpolicyid"; 131 final public static String ITMDT_STYLPTH_STYLEPATHID = "itmdt_stylpth_stylepathid"; 132 final public static String ITMDT_FROMTIME = "itmdt_fromtime"; 133 final public static String ITMDT_THRUTIME = "itmdt_thrutime"; 134 135 final private static EntityIdGenerator entityIdGenerator = new EntityIdGenerator(ItemDetailConstants.COMPONENT_VENDOR_NAME, ItemDetailConstants.ENTITY_TYPE_NAME); 136 137 /** Creates a new instance of ItemDetailFactory */ 138 protected ItemDetailFactory() { 139 super(); 140 } 141 142 public static ItemDetailFactory getInstance() { 143 return CDI.current().select(ItemDetailFactory.class).get(); 144 } 145 146 @Override 147 public String getPKColumn() { 148 return PK_COLUMN; 149 } 150 151 @Override 152 public String getAllColumns() { 153 return ALL_COLUMNS; 154 } 155 156 @Override 157 public String getTableName() { 158 return TABLE_NAME; 159 } 160 161 @Override 162 public String getComponentVendorName() { 163 return ItemDetailConstants.COMPONENT_VENDOR_NAME; 164 } 165 166 @Override 167 public String getEntityTypeName() { 168 return ItemDetailConstants.ENTITY_TYPE_NAME; 169 } 170 171 public PreparedStatement prepareStatement(String query) { 172 return ThreadSession.currentSession().prepareStatement(ItemDetailFactory.class, query); 173 } 174 175 public ItemDetailPK getNextPK() { 176 return new ItemDetailPK(entityIdGenerator.getNextEntityId()); 177 } 178 179 public Set<ItemDetailPK> getPKsFromResultSetAsSet(ResultSet rs) 180 throws PersistenceDatabaseException { 181 Set<ItemDetailPK> _result = new HashSet<>(); 182 183 try { 184 while(rs.next()) { 185 _result.add(getPKFromResultSet(rs)); 186 } 187 } catch (SQLException se) { 188 throw new PersistenceDatabaseException(se); 189 } 190 191 return _result; 192 } 193 194 public java.util.List<ItemDetailPK> getPKsFromResultSetAsList(ResultSet rs) 195 throws PersistenceDatabaseException { 196 java.util.List<ItemDetailPK> _result = new ArrayList<>(); 197 198 try { 199 while(rs.next()) { 200 _result.add(getPKFromResultSet(rs)); 201 } 202 } catch (SQLException se) { 203 throw new PersistenceDatabaseException(se); 204 } 205 206 return _result; 207 } 208 209 public ItemDetailPK getPKFromResultSet(ResultSet rs) 210 throws PersistenceDatabaseException { 211 ItemDetailPK _result; 212 213 try { 214 long itmdt_itemdetailid = rs.getLong(ITMDT_ITEMDETAILID); 215 Long _entityId = rs.wasNull() ? null : itmdt_itemdetailid; 216 217 _result = new ItemDetailPK(_entityId); 218 } catch (SQLException se) { 219 throw new PersistenceDatabaseException(se); 220 } 221 222 return _result; 223 } 224 225 public java.util.List<ItemDetailValue> getValuesFromPKs(Session session, Collection<ItemDetailPK> pks) 226 throws PersistenceDatabaseException { 227 java.util.List<ItemDetailValue> _values = new ArrayList<>(pks.size()); 228 229 for(ItemDetailPK _pk: pks) { 230 _values.add(getValueFromPK(session, _pk)); 231 } 232 233 return _values; 234 } 235 236 public ItemDetailValue getValueFromPK(Session session, ItemDetailPK pk) 237 throws PersistenceDatabaseException { 238 ItemDetailValue _value; 239 240 // See if we already have the entity in the session cache 241 ItemDetail _entity = (ItemDetail)session.getEntity(pk); 242 if(_entity == null) 243 _value = getEntityFromPK(session, EntityPermission.READ_ONLY, pk).getItemDetailValue(); 244 else 245 _value = _entity.getItemDetailValue(); 246 247 return _value; 248 } 249 250 public java.util.List<ItemDetailValue> getValuesFromResultSet(Session session, ResultSet rs) 251 throws PersistenceDatabaseException { 252 java.util.List<ItemDetailValue> _result = new ArrayList<>(); 253 254 try { 255 while(rs.next()) { 256 _result.add(getValueFromResultSet(session, rs)); 257 } 258 } catch (SQLException se) { 259 throw new PersistenceDatabaseException(se); 260 } 261 262 return _result; 263 } 264 265 public ItemDetailValue getValueFromResultSet(Session session, ResultSet rs) 266 throws PersistenceDatabaseException { 267 ItemDetailValue _value; 268 269 try { 270 Long itmdt_itemdetailid = rs.getLong(ITMDT_ITEMDETAILID); 271 ItemDetailPK _pk = new ItemDetailPK(itmdt_itemdetailid); 272 273 // See if we already have the entity in the session cache 274 ItemDetail _entity = (ItemDetail)session.getEntity(_pk); 275 276 if(_entity == null) { 277 Long itmdt_itm_itemid = rs.getLong(ITMDT_ITM_ITEMID); 278 if(rs.wasNull()) 279 itmdt_itm_itemid = null; 280 281 String itmdt_itemname = rs.getString(ITMDT_ITEMNAME); 282 if(rs.wasNull()) 283 itmdt_itemname = null; 284 285 Long itmdt_ityp_itemtypeid = rs.getLong(ITMDT_ITYP_ITEMTYPEID); 286 if(rs.wasNull()) 287 itmdt_ityp_itemtypeid = null; 288 289 Long itmdt_iutyp_itemusetypeid = rs.getLong(ITMDT_IUTYP_ITEMUSETYPEID); 290 if(rs.wasNull()) 291 itmdt_iutyp_itemusetypeid = null; 292 293 Long itmdt_ic_itemcategoryid = rs.getLong(ITMDT_IC_ITEMCATEGORYID); 294 if(rs.wasNull()) 295 itmdt_ic_itemcategoryid = null; 296 297 Long itmdt_iactgc_itemaccountingcategoryid = rs.getLong(ITMDT_IACTGC_ITEMACCOUNTINGCATEGORYID); 298 if(rs.wasNull()) 299 itmdt_iactgc_itemaccountingcategoryid = null; 300 301 Long itmdt_iprchc_itempurchasingcategoryid = rs.getLong(ITMDT_IPRCHC_ITEMPURCHASINGCATEGORYID); 302 if(rs.wasNull()) 303 itmdt_iprchc_itempurchasingcategoryid = null; 304 305 Long itmdt_companypartyid = rs.getLong(ITMDT_COMPANYPARTYID); 306 if(rs.wasNull()) 307 itmdt_companypartyid = null; 308 309 Long itmdt_idlvrtyp_itemdeliverytypeid = rs.getLong(ITMDT_IDLVRTYP_ITEMDELIVERYTYPEID); 310 if(rs.wasNull()) 311 itmdt_idlvrtyp_itemdeliverytypeid = null; 312 313 Long itmdt_iinvtyp_iteminventorytypeid = rs.getLong(ITMDT_IINVTYP_ITEMINVENTORYTYPEID); 314 if(rs.wasNull()) 315 itmdt_iinvtyp_iteminventorytypeid = null; 316 317 Boolean itmdt_inventoryserialized = rs.getInt(ITMDT_INVENTORYSERIALIZED) == 1; 318 if(rs.wasNull()) 319 itmdt_inventoryserialized = null; 320 321 Long itmdt_serialnumbersequenceid = rs.getLong(ITMDT_SERIALNUMBERSEQUENCEID); 322 if(rs.wasNull()) 323 itmdt_serialnumbersequenceid = null; 324 325 Boolean itmdt_shippingchargeexempt = rs.getInt(ITMDT_SHIPPINGCHARGEEXEMPT) == 1; 326 if(rs.wasNull()) 327 itmdt_shippingchargeexempt = null; 328 329 Long itmdt_shippingstarttime = rs.getLong(ITMDT_SHIPPINGSTARTTIME); 330 if(rs.wasNull()) 331 itmdt_shippingstarttime = null; 332 333 Long itmdt_shippingendtime = rs.getLong(ITMDT_SHIPPINGENDTIME); 334 if(rs.wasNull()) 335 itmdt_shippingendtime = null; 336 337 Long itmdt_salesorderstarttime = rs.getLong(ITMDT_SALESORDERSTARTTIME); 338 if(rs.wasNull()) 339 itmdt_salesorderstarttime = null; 340 341 Long itmdt_salesorderendtime = rs.getLong(ITMDT_SALESORDERENDTIME); 342 if(rs.wasNull()) 343 itmdt_salesorderendtime = null; 344 345 Long itmdt_purchaseorderstarttime = rs.getLong(ITMDT_PURCHASEORDERSTARTTIME); 346 if(rs.wasNull()) 347 itmdt_purchaseorderstarttime = null; 348 349 Long itmdt_purchaseorderendtime = rs.getLong(ITMDT_PURCHASEORDERENDTIME); 350 if(rs.wasNull()) 351 itmdt_purchaseorderendtime = null; 352 353 Boolean itmdt_allowclubdiscounts = rs.getInt(ITMDT_ALLOWCLUBDISCOUNTS) == 1; 354 if(rs.wasNull()) 355 itmdt_allowclubdiscounts = null; 356 357 Boolean itmdt_allowcoupondiscounts = rs.getInt(ITMDT_ALLOWCOUPONDISCOUNTS) == 1; 358 if(rs.wasNull()) 359 itmdt_allowcoupondiscounts = null; 360 361 Boolean itmdt_allowassociatepayments = rs.getInt(ITMDT_ALLOWASSOCIATEPAYMENTS) == 1; 362 if(rs.wasNull()) 363 itmdt_allowassociatepayments = null; 364 365 Long itmdt_uomk_unitofmeasurekindid = rs.getLong(ITMDT_UOMK_UNITOFMEASUREKINDID); 366 if(rs.wasNull()) 367 itmdt_uomk_unitofmeasurekindid = null; 368 369 Long itmdt_ipt_itempricetypeid = rs.getLong(ITMDT_IPT_ITEMPRICETYPEID); 370 if(rs.wasNull()) 371 itmdt_ipt_itempricetypeid = null; 372 373 Long itmdt_cnclplcy_cancellationpolicyid = rs.getLong(ITMDT_CNCLPLCY_CANCELLATIONPOLICYID); 374 if(rs.wasNull()) 375 itmdt_cnclplcy_cancellationpolicyid = null; 376 377 Long itmdt_rtnplcy_returnpolicyid = rs.getLong(ITMDT_RTNPLCY_RETURNPOLICYID); 378 if(rs.wasNull()) 379 itmdt_rtnplcy_returnpolicyid = null; 380 381 Long itmdt_stylpth_stylepathid = rs.getLong(ITMDT_STYLPTH_STYLEPATHID); 382 if(rs.wasNull()) 383 itmdt_stylpth_stylepathid = null; 384 385 Long itmdt_fromtime = rs.getLong(ITMDT_FROMTIME); 386 if(rs.wasNull()) 387 itmdt_fromtime = null; 388 389 Long itmdt_thrutime = rs.getLong(ITMDT_THRUTIME); 390 if(rs.wasNull()) 391 itmdt_thrutime = null; 392 393 _value = new ItemDetailValue(_pk, new ItemPK(itmdt_itm_itemid), itmdt_itemname, new ItemTypePK(itmdt_ityp_itemtypeid), new ItemUseTypePK(itmdt_iutyp_itemusetypeid), new ItemCategoryPK(itmdt_ic_itemcategoryid), new ItemAccountingCategoryPK(itmdt_iactgc_itemaccountingcategoryid), new ItemPurchasingCategoryPK(itmdt_iprchc_itempurchasingcategoryid), new PartyPK(itmdt_companypartyid), new ItemDeliveryTypePK(itmdt_idlvrtyp_itemdeliverytypeid), new ItemInventoryTypePK(itmdt_iinvtyp_iteminventorytypeid), itmdt_inventoryserialized, new SequencePK(itmdt_serialnumbersequenceid), itmdt_shippingchargeexempt, itmdt_shippingstarttime, itmdt_shippingendtime, itmdt_salesorderstarttime, itmdt_salesorderendtime, itmdt_purchaseorderstarttime, itmdt_purchaseorderendtime, itmdt_allowclubdiscounts, itmdt_allowcoupondiscounts, itmdt_allowassociatepayments, new UnitOfMeasureKindPK(itmdt_uomk_unitofmeasurekindid), new ItemPriceTypePK(itmdt_ipt_itempricetypeid), new CancellationPolicyPK(itmdt_cnclplcy_cancellationpolicyid), new ReturnPolicyPK(itmdt_rtnplcy_returnpolicyid), new StylePathPK(itmdt_stylpth_stylepathid), itmdt_fromtime, itmdt_thrutime); 394 } else 395 _value = _entity.getItemDetailValue(); 396 } catch (SQLException se) { 397 throw new PersistenceDatabaseException(se); 398 } 399 400 return _value; 401 } 402 403 public java.util.List<ItemDetail> getEntitiesFromPKs(EntityPermission entityPermission, Collection<ItemDetailPK> pks) 404 throws PersistenceDatabaseException { 405 return getEntitiesFromPKs(ThreadSession.currentSession(), entityPermission, pks); 406 } 407 408 public java.util.List<ItemDetail> getEntitiesFromPKs(Session session, EntityPermission entityPermission, Collection<ItemDetailPK> pks) 409 throws PersistenceDatabaseException { 410 java.util.List<ItemDetail> _entities = new ArrayList<>(pks.size()); 411 412 for(ItemDetailPK _pk: pks) { 413 _entities.add(getEntityFromPK(session, entityPermission, _pk)); 414 } 415 416 return _entities; 417 } 418 419 public ItemDetail getEntityFromValue(EntityPermission entityPermission, ItemDetailValue value) { 420 return getEntityFromPK(ThreadSession.currentSession(), entityPermission, value.getPrimaryKey()); 421 } 422 423 public ItemDetail getEntityFromValue(Session session, EntityPermission entityPermission, ItemDetailValue value) { 424 return getEntityFromPK(session, entityPermission, value.getPrimaryKey()); 425 } 426 427 public ItemDetail getEntityFromPK(EntityPermission entityPermission, ItemDetailPK pk) 428 throws PersistenceDatabaseException { 429 return getEntityFromPK(ThreadSession.currentSession(), entityPermission, pk); 430 } 431 432 public ItemDetail getEntityFromCache(Session session, ItemDetailPK pk) { 433 ItemDetailValue _value = (ItemDetailValue)session.getValueCache().get(pk); 434 435 return _value == null ? null : new ItemDetail(_value, EntityPermission.READ_ONLY); 436 } 437 438 public ItemDetail getEntityFromPK(Session session, EntityPermission entityPermission, ItemDetailPK pk) 439 throws PersistenceDatabaseException { 440 ItemDetail _entity; 441 442 // See if we already have the entity in the session cache 443 _entity = (ItemDetail)session.getEntity(pk); 444 if(_entity != null) { 445 // If the requested permission is READ_WRITE, and the cached permission is 446 // READ_ONLY, then pretend that the cached object wasn't found, and create 447 // a new entity that is READ_WRITE. 448 if(entityPermission.equals(EntityPermission.READ_WRITE)) { 449 if(_entity.getEntityPermission().equals(EntityPermission.READ_ONLY)) 450 _entity = null; 451 } 452 } 453 454 if(_entity == null && entityPermission.equals(EntityPermission.READ_ONLY)) { 455 _entity = getEntityFromCache(session, pk); 456 } 457 458 if(_entity == null) { 459 PreparedStatement _ps = session.prepareStatement(entityPermission.equals(EntityPermission.READ_ONLY)? SQL_SELECT_READ_ONLY: SQL_SELECT_READ_WRITE); 460 long _entityId = pk.getEntityId(); 461 ResultSet _rs = null; 462 463 try { 464 _ps.setLong(1, _entityId); 465 _rs = _ps.executeQuery(); 466 if(_rs.next()) { 467 _entity = getEntityFromResultSet(session, entityPermission, _rs); 468 } 469 } catch (SQLException se) { 470 throw new PersistenceDatabaseException(se); 471 } finally { 472 if(_rs != null) { 473 try { 474 _rs.close(); 475 } catch (SQLException se) { 476 // do nothing 477 } 478 } 479 } 480 } 481 482 return _entity; 483 } 484 485 public Set<ItemDetailPK> getPKsFromQueryAsSet(PreparedStatement ps, final Object... params) 486 throws PersistenceDatabaseException { 487 Set<ItemDetailPK> _pks; 488 ResultSet _rs = null; 489 490 try { 491 if(params.length != 0) { 492 Session.setQueryParams(ps, params); 493 } 494 495 _rs = ps.executeQuery(); 496 _pks = getPKsFromResultSetAsSet(_rs); 497 _rs.close(); 498 } catch (SQLException se) { 499 throw new PersistenceDatabaseException(se); 500 } finally { 501 if(_rs != null) { 502 try { 503 _rs.close(); 504 } catch (SQLException se) { 505 // do nothing 506 } 507 } 508 } 509 510 return _pks; 511 } 512 513 public java.util.List<ItemDetailPK> getPKsFromQueryAsList(PreparedStatement ps, final Object... params) 514 throws PersistenceDatabaseException { 515 java.util.List<ItemDetailPK> _pks; 516 ResultSet _rs = null; 517 518 try { 519 if(params.length != 0) { 520 Session.setQueryParams(ps, params); 521 } 522 523 _rs = ps.executeQuery(); 524 _pks = getPKsFromResultSetAsList(_rs); 525 _rs.close(); 526 } catch (SQLException se) { 527 throw new PersistenceDatabaseException(se); 528 } finally { 529 if(_rs != null) { 530 try { 531 _rs.close(); 532 } catch (SQLException se) { 533 // do nothing 534 } 535 } 536 } 537 538 return _pks; 539 } 540 541 public ItemDetailPK getPKFromQuery(PreparedStatement ps, final Object... params) 542 throws PersistenceDatabaseException { 543 ItemDetailPK _pk = null; 544 ResultSet _rs = null; 545 546 try { 547 if(params.length != 0) { 548 Session.setQueryParams(ps, params); 549 } 550 551 _rs = ps.executeQuery(); 552 if(_rs.next()) { 553 _pk = getPKFromResultSet(_rs); 554 } 555 _rs.close(); 556 } catch (SQLException se) { 557 throw new PersistenceDatabaseException(se); 558 } finally { 559 if(_rs != null) { 560 try { 561 _rs.close(); 562 } catch (SQLException se) { 563 // do nothing 564 } 565 } 566 } 567 568 return _pk; 569 } 570 571 public java.util.List<ItemDetail> getEntitiesFromQuery(Session session, EntityPermission entityPermission, Map<EntityPermission, String>queryMap, final Object... params) 572 throws PersistenceDatabaseException { 573 PreparedStatement ps = session.prepareStatement(ItemDetailFactory.class, queryMap.get(entityPermission)); 574 575 return getEntitiesFromQuery(session, entityPermission, ps, params); 576 } 577 578 public java.util.List<ItemDetail> getEntitiesFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap, final Object... params) 579 throws PersistenceDatabaseException { 580 Session session = ThreadSession.currentSession(); 581 PreparedStatement ps = session.prepareStatement(ItemDetailFactory.class, queryMap.get(entityPermission)); 582 583 return getEntitiesFromQuery(session, entityPermission, ps, params); 584 } 585 586 public java.util.List<ItemDetail> getEntitiesFromQuery(Session session, EntityPermission entityPermission, Map<EntityPermission, String>queryMap) 587 throws PersistenceDatabaseException { 588 PreparedStatement ps = session.prepareStatement(ItemDetailFactory.class, queryMap.get(entityPermission)); 589 590 return getEntitiesFromQuery(session, entityPermission, ps); 591 } 592 593 public java.util.List<ItemDetail> getEntitiesFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap) 594 throws PersistenceDatabaseException { 595 Session session = ThreadSession.currentSession(); 596 PreparedStatement ps = session.prepareStatement(ItemDetailFactory.class, queryMap.get(entityPermission)); 597 598 return getEntitiesFromQuery(session, entityPermission, ps); 599 } 600 601 public java.util.List<ItemDetail> getEntitiesFromQuery(EntityPermission entityPermission, PreparedStatement ps) 602 throws PersistenceDatabaseException { 603 return getEntitiesFromQuery(ThreadSession.currentSession(), entityPermission, ps); 604 } 605 606 public java.util.List<ItemDetail> getEntitiesFromQuery(EntityPermission entityPermission, PreparedStatement ps, final Object... params) 607 throws PersistenceDatabaseException { 608 return getEntitiesFromQuery(ThreadSession.currentSession(), entityPermission, ps, params); 609 } 610 611 public java.util.List<ItemDetail> getEntitiesFromQuery(Session session, EntityPermission entityPermission, PreparedStatement ps, final Object... params) 612 throws PersistenceDatabaseException { 613 java.util.List<ItemDetail> _entities; 614 ResultSet _rs = null; 615 616 try { 617 if(params.length != 0) { 618 Session.setQueryParams(ps, params); 619 } 620 621 _rs = ps.executeQuery(); 622 _entities = getEntitiesFromResultSet(session, entityPermission, _rs); 623 _rs.close(); 624 } catch (SQLException se) { 625 throw new PersistenceDatabaseException(se); 626 } finally { 627 if(_rs != null) { 628 try { 629 _rs.close(); 630 } catch (SQLException se) { 631 // do nothing 632 } 633 } 634 } 635 636 return _entities; 637 } 638 639 public ItemDetail getEntityFromQuery(Session session, EntityPermission entityPermission, Map<EntityPermission, String>queryMap, final Object... params) 640 throws PersistenceDatabaseException { 641 PreparedStatement ps = session.prepareStatement(ItemDetailFactory.class, queryMap.get(entityPermission)); 642 643 return getEntityFromQuery(session, entityPermission, ps, params); 644 } 645 646 public ItemDetail getEntityFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap, final Object... params) 647 throws PersistenceDatabaseException { 648 Session session = ThreadSession.currentSession(); 649 PreparedStatement ps = session.prepareStatement(ItemDetailFactory.class, queryMap.get(entityPermission)); 650 651 return getEntityFromQuery(session, entityPermission, ps, params); 652 } 653 654 public ItemDetail getEntityFromQuery(Session session, EntityPermission entityPermission, Map<EntityPermission, String>queryMap) 655 throws PersistenceDatabaseException { 656 PreparedStatement ps = session.prepareStatement(ItemDetailFactory.class, queryMap.get(entityPermission)); 657 658 return getEntityFromQuery(session, entityPermission, ps); 659 } 660 661 public ItemDetail getEntityFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap) 662 throws PersistenceDatabaseException { 663 Session session = ThreadSession.currentSession(); 664 PreparedStatement ps = session.prepareStatement(ItemDetailFactory.class, queryMap.get(entityPermission)); 665 666 return getEntityFromQuery(session, entityPermission, ps); 667 } 668 669 public ItemDetail getEntityFromQuery(EntityPermission entityPermission, PreparedStatement ps) 670 throws PersistenceDatabaseException { 671 return getEntityFromQuery(ThreadSession.currentSession(), entityPermission, ps); 672 } 673 674 public ItemDetail getEntityFromQuery(EntityPermission entityPermission, PreparedStatement ps, final Object... params) 675 throws PersistenceDatabaseException { 676 return getEntityFromQuery(ThreadSession.currentSession(), entityPermission, ps, params); 677 } 678 679 public ItemDetail getEntityFromQuery(Session session, EntityPermission entityPermission, PreparedStatement ps, final Object... params) 680 throws PersistenceDatabaseException { 681 ItemDetail _entity = null; 682 ResultSet _rs = null; 683 684 try { 685 if(params.length != 0) { 686 Session.setQueryParams(ps, params); 687 } 688 689 _rs = ps.executeQuery(); 690 if(_rs.next()) { 691 _entity = getEntityFromResultSet(session, entityPermission, _rs); 692 } 693 _rs.close(); 694 } catch (SQLException se) { 695 throw new PersistenceDatabaseException(se); 696 } finally { 697 if(_rs != null) { 698 try { 699 _rs.close(); 700 } catch (SQLException se) { 701 // do nothing 702 } 703 } 704 } 705 706 return _entity; 707 } 708 709 public java.util.List<ItemDetail> getEntitiesFromResultSet(EntityPermission entityPermission, ResultSet rs) 710 throws PersistenceDatabaseException { 711 return getEntitiesFromResultSet(ThreadSession.currentSession(), entityPermission, rs); 712 } 713 714 public java.util.List<ItemDetail> getEntitiesFromResultSet(Session session, EntityPermission entityPermission, ResultSet rs) 715 throws PersistenceDatabaseException { 716 java.util.List<ItemDetail> _result = new ArrayList<>(); 717 718 try { 719 while(rs.next()) { 720 _result.add(getEntityFromResultSet(session, entityPermission, rs)); 721 } 722 } catch (SQLException se) { 723 throw new PersistenceDatabaseException(se); 724 } 725 726 return _result; 727 } 728 729 public ItemDetail getEntityFromResultSet(EntityPermission entityPermission, ResultSet rs) 730 throws PersistenceDatabaseException { 731 return getEntityFromResultSet(ThreadSession.currentSession(), entityPermission, rs); 732 } 733 734 public ItemDetail getEntityFromResultSet(Session session, EntityPermission entityPermission, ResultSet rs) 735 throws PersistenceDatabaseException { 736 ItemDetail _entity; 737 738 try { 739 Long itmdt_itemdetailid = rs.getLong(ITMDT_ITEMDETAILID); 740 ItemDetailPK _pk = new ItemDetailPK(itmdt_itemdetailid); 741 742 // See if we already have the entity in the session cache 743 _entity = (ItemDetail)session.getEntity(_pk); 744 if(_entity != null) { 745 // If the requested permission is READ_WRITE, and the cached permission is 746 // READ_ONLY, then pretend that the cached object wasn't found, and create 747 // a new entity that is READ_WRITE. 748 if(entityPermission.equals(EntityPermission.READ_WRITE)) { 749 if(_entity.getEntityPermission().equals(EntityPermission.READ_ONLY)) 750 _entity = null; 751 } 752 } 753 boolean foundInSessionCache = _entity != null; 754 755 if(_entity == null && entityPermission.equals(EntityPermission.READ_ONLY)) { 756 _entity = getEntityFromCache(session, _pk); 757 } 758 759 if(_entity == null) { 760 Long itmdt_itm_itemid = rs.getLong(ITMDT_ITM_ITEMID); 761 if(rs.wasNull()) 762 itmdt_itm_itemid = null; 763 764 String itmdt_itemname = rs.getString(ITMDT_ITEMNAME); 765 if(rs.wasNull()) 766 itmdt_itemname = null; 767 768 Long itmdt_ityp_itemtypeid = rs.getLong(ITMDT_ITYP_ITEMTYPEID); 769 if(rs.wasNull()) 770 itmdt_ityp_itemtypeid = null; 771 772 Long itmdt_iutyp_itemusetypeid = rs.getLong(ITMDT_IUTYP_ITEMUSETYPEID); 773 if(rs.wasNull()) 774 itmdt_iutyp_itemusetypeid = null; 775 776 Long itmdt_ic_itemcategoryid = rs.getLong(ITMDT_IC_ITEMCATEGORYID); 777 if(rs.wasNull()) 778 itmdt_ic_itemcategoryid = null; 779 780 Long itmdt_iactgc_itemaccountingcategoryid = rs.getLong(ITMDT_IACTGC_ITEMACCOUNTINGCATEGORYID); 781 if(rs.wasNull()) 782 itmdt_iactgc_itemaccountingcategoryid = null; 783 784 Long itmdt_iprchc_itempurchasingcategoryid = rs.getLong(ITMDT_IPRCHC_ITEMPURCHASINGCATEGORYID); 785 if(rs.wasNull()) 786 itmdt_iprchc_itempurchasingcategoryid = null; 787 788 Long itmdt_companypartyid = rs.getLong(ITMDT_COMPANYPARTYID); 789 if(rs.wasNull()) 790 itmdt_companypartyid = null; 791 792 Long itmdt_idlvrtyp_itemdeliverytypeid = rs.getLong(ITMDT_IDLVRTYP_ITEMDELIVERYTYPEID); 793 if(rs.wasNull()) 794 itmdt_idlvrtyp_itemdeliverytypeid = null; 795 796 Long itmdt_iinvtyp_iteminventorytypeid = rs.getLong(ITMDT_IINVTYP_ITEMINVENTORYTYPEID); 797 if(rs.wasNull()) 798 itmdt_iinvtyp_iteminventorytypeid = null; 799 800 Boolean itmdt_inventoryserialized = rs.getInt(ITMDT_INVENTORYSERIALIZED) == 1; 801 if(rs.wasNull()) 802 itmdt_inventoryserialized = null; 803 804 Long itmdt_serialnumbersequenceid = rs.getLong(ITMDT_SERIALNUMBERSEQUENCEID); 805 if(rs.wasNull()) 806 itmdt_serialnumbersequenceid = null; 807 808 Boolean itmdt_shippingchargeexempt = rs.getInt(ITMDT_SHIPPINGCHARGEEXEMPT) == 1; 809 if(rs.wasNull()) 810 itmdt_shippingchargeexempt = null; 811 812 Long itmdt_shippingstarttime = rs.getLong(ITMDT_SHIPPINGSTARTTIME); 813 if(rs.wasNull()) 814 itmdt_shippingstarttime = null; 815 816 Long itmdt_shippingendtime = rs.getLong(ITMDT_SHIPPINGENDTIME); 817 if(rs.wasNull()) 818 itmdt_shippingendtime = null; 819 820 Long itmdt_salesorderstarttime = rs.getLong(ITMDT_SALESORDERSTARTTIME); 821 if(rs.wasNull()) 822 itmdt_salesorderstarttime = null; 823 824 Long itmdt_salesorderendtime = rs.getLong(ITMDT_SALESORDERENDTIME); 825 if(rs.wasNull()) 826 itmdt_salesorderendtime = null; 827 828 Long itmdt_purchaseorderstarttime = rs.getLong(ITMDT_PURCHASEORDERSTARTTIME); 829 if(rs.wasNull()) 830 itmdt_purchaseorderstarttime = null; 831 832 Long itmdt_purchaseorderendtime = rs.getLong(ITMDT_PURCHASEORDERENDTIME); 833 if(rs.wasNull()) 834 itmdt_purchaseorderendtime = null; 835 836 Boolean itmdt_allowclubdiscounts = rs.getInt(ITMDT_ALLOWCLUBDISCOUNTS) == 1; 837 if(rs.wasNull()) 838 itmdt_allowclubdiscounts = null; 839 840 Boolean itmdt_allowcoupondiscounts = rs.getInt(ITMDT_ALLOWCOUPONDISCOUNTS) == 1; 841 if(rs.wasNull()) 842 itmdt_allowcoupondiscounts = null; 843 844 Boolean itmdt_allowassociatepayments = rs.getInt(ITMDT_ALLOWASSOCIATEPAYMENTS) == 1; 845 if(rs.wasNull()) 846 itmdt_allowassociatepayments = null; 847 848 Long itmdt_uomk_unitofmeasurekindid = rs.getLong(ITMDT_UOMK_UNITOFMEASUREKINDID); 849 if(rs.wasNull()) 850 itmdt_uomk_unitofmeasurekindid = null; 851 852 Long itmdt_ipt_itempricetypeid = rs.getLong(ITMDT_IPT_ITEMPRICETYPEID); 853 if(rs.wasNull()) 854 itmdt_ipt_itempricetypeid = null; 855 856 Long itmdt_cnclplcy_cancellationpolicyid = rs.getLong(ITMDT_CNCLPLCY_CANCELLATIONPOLICYID); 857 if(rs.wasNull()) 858 itmdt_cnclplcy_cancellationpolicyid = null; 859 860 Long itmdt_rtnplcy_returnpolicyid = rs.getLong(ITMDT_RTNPLCY_RETURNPOLICYID); 861 if(rs.wasNull()) 862 itmdt_rtnplcy_returnpolicyid = null; 863 864 Long itmdt_stylpth_stylepathid = rs.getLong(ITMDT_STYLPTH_STYLEPATHID); 865 if(rs.wasNull()) 866 itmdt_stylpth_stylepathid = null; 867 868 Long itmdt_fromtime = rs.getLong(ITMDT_FROMTIME); 869 if(rs.wasNull()) 870 itmdt_fromtime = null; 871 872 Long itmdt_thrutime = rs.getLong(ITMDT_THRUTIME); 873 if(rs.wasNull()) 874 itmdt_thrutime = null; 875 876 ItemDetailValue _value = new ItemDetailValue(_pk, itmdt_itm_itemid == null? null: new ItemPK(itmdt_itm_itemid), itmdt_itemname, itmdt_ityp_itemtypeid == null? null: new ItemTypePK(itmdt_ityp_itemtypeid), itmdt_iutyp_itemusetypeid == null? null: new ItemUseTypePK(itmdt_iutyp_itemusetypeid), itmdt_ic_itemcategoryid == null? null: new ItemCategoryPK(itmdt_ic_itemcategoryid), itmdt_iactgc_itemaccountingcategoryid == null? null: new ItemAccountingCategoryPK(itmdt_iactgc_itemaccountingcategoryid), itmdt_iprchc_itempurchasingcategoryid == null? null: new ItemPurchasingCategoryPK(itmdt_iprchc_itempurchasingcategoryid), itmdt_companypartyid == null? null: new PartyPK(itmdt_companypartyid), itmdt_idlvrtyp_itemdeliverytypeid == null? null: new ItemDeliveryTypePK(itmdt_idlvrtyp_itemdeliverytypeid), itmdt_iinvtyp_iteminventorytypeid == null? null: new ItemInventoryTypePK(itmdt_iinvtyp_iteminventorytypeid), itmdt_inventoryserialized, itmdt_serialnumbersequenceid == null? null: new SequencePK(itmdt_serialnumbersequenceid), itmdt_shippingchargeexempt, itmdt_shippingstarttime, itmdt_shippingendtime, itmdt_salesorderstarttime, itmdt_salesorderendtime, itmdt_purchaseorderstarttime, itmdt_purchaseorderendtime, itmdt_allowclubdiscounts, itmdt_allowcoupondiscounts, itmdt_allowassociatepayments, itmdt_uomk_unitofmeasurekindid == null? null: new UnitOfMeasureKindPK(itmdt_uomk_unitofmeasurekindid), itmdt_ipt_itempricetypeid == null? null: new ItemPriceTypePK(itmdt_ipt_itempricetypeid), itmdt_cnclplcy_cancellationpolicyid == null? null: new CancellationPolicyPK(itmdt_cnclplcy_cancellationpolicyid), itmdt_rtnplcy_returnpolicyid == null? null: new ReturnPolicyPK(itmdt_rtnplcy_returnpolicyid), itmdt_stylpth_stylepathid == null? null: new StylePathPK(itmdt_stylpth_stylepathid), itmdt_fromtime, itmdt_thrutime); 877 _entity = new ItemDetail(_value, entityPermission); 878 } 879 880 if(!foundInSessionCache) { 881 if(entityPermission.equals(EntityPermission.READ_ONLY)) { 882 session.putReadOnlyEntity(_pk, _entity); 883 session.getValueCache().put(_entity.getItemDetailValue()); 884 } else { 885 session.putReadWriteEntity(_pk, _entity); 886 } 887 } 888 } catch (SQLException se) { 889 throw new PersistenceDatabaseException(se); 890 } 891 892 return _entity; 893 } 894 895 public ItemDetail create(Session session, Item item, String itemName, ItemType itemType, ItemUseType itemUseType, ItemCategory itemCategory, ItemAccountingCategory itemAccountingCategory, ItemPurchasingCategory itemPurchasingCategory, Party companyParty, ItemDeliveryType itemDeliveryType, ItemInventoryType itemInventoryType, Boolean inventorySerialized, Sequence serialNumberSequence, Boolean shippingChargeExempt, Long shippingStartTime, Long shippingEndTime, Long salesOrderStartTime, Long salesOrderEndTime, Long purchaseOrderStartTime, Long purchaseOrderEndTime, Boolean allowClubDiscounts, Boolean allowCouponDiscounts, Boolean allowAssociatePayments, UnitOfMeasureKind unitOfMeasureKind, ItemPriceType itemPriceType, CancellationPolicy cancellationPolicy, ReturnPolicy returnPolicy, StylePath stylePath, Long fromTime, Long thruTime) 896 throws PersistenceDatabaseException, PersistenceNotNullException { 897 return create(session, item == null ? null : item.getPrimaryKey(), itemName, itemType == null ? null : itemType.getPrimaryKey(), itemUseType == null ? null : itemUseType.getPrimaryKey(), itemCategory == null ? null : itemCategory.getPrimaryKey(), itemAccountingCategory == null ? null : itemAccountingCategory.getPrimaryKey(), itemPurchasingCategory == null ? null : itemPurchasingCategory.getPrimaryKey(), companyParty == null ? null : companyParty.getPrimaryKey(), itemDeliveryType == null ? null : itemDeliveryType.getPrimaryKey(), itemInventoryType == null ? null : itemInventoryType.getPrimaryKey(), inventorySerialized, serialNumberSequence == null ? null : serialNumberSequence.getPrimaryKey(), shippingChargeExempt, shippingStartTime, shippingEndTime, salesOrderStartTime, salesOrderEndTime, purchaseOrderStartTime, purchaseOrderEndTime, allowClubDiscounts, allowCouponDiscounts, allowAssociatePayments, unitOfMeasureKind == null ? null : unitOfMeasureKind.getPrimaryKey(), itemPriceType == null ? null : itemPriceType.getPrimaryKey(), cancellationPolicy == null ? null : cancellationPolicy.getPrimaryKey(), returnPolicy == null ? null : returnPolicy.getPrimaryKey(), stylePath == null ? null : stylePath.getPrimaryKey(), fromTime, thruTime); 898 } 899 900 public ItemDetail create(Item item, String itemName, ItemType itemType, ItemUseType itemUseType, ItemCategory itemCategory, ItemAccountingCategory itemAccountingCategory, ItemPurchasingCategory itemPurchasingCategory, Party companyParty, ItemDeliveryType itemDeliveryType, ItemInventoryType itemInventoryType, Boolean inventorySerialized, Sequence serialNumberSequence, Boolean shippingChargeExempt, Long shippingStartTime, Long shippingEndTime, Long salesOrderStartTime, Long salesOrderEndTime, Long purchaseOrderStartTime, Long purchaseOrderEndTime, Boolean allowClubDiscounts, Boolean allowCouponDiscounts, Boolean allowAssociatePayments, UnitOfMeasureKind unitOfMeasureKind, ItemPriceType itemPriceType, CancellationPolicy cancellationPolicy, ReturnPolicy returnPolicy, StylePath stylePath, Long fromTime, Long thruTime) 901 throws PersistenceDatabaseException, PersistenceNotNullException { 902 return create(ThreadSession.currentSession(), item == null ? null : item.getPrimaryKey(), itemName, itemType == null ? null : itemType.getPrimaryKey(), itemUseType == null ? null : itemUseType.getPrimaryKey(), itemCategory == null ? null : itemCategory.getPrimaryKey(), itemAccountingCategory == null ? null : itemAccountingCategory.getPrimaryKey(), itemPurchasingCategory == null ? null : itemPurchasingCategory.getPrimaryKey(), companyParty == null ? null : companyParty.getPrimaryKey(), itemDeliveryType == null ? null : itemDeliveryType.getPrimaryKey(), itemInventoryType == null ? null : itemInventoryType.getPrimaryKey(), inventorySerialized, serialNumberSequence == null ? null : serialNumberSequence.getPrimaryKey(), shippingChargeExempt, shippingStartTime, shippingEndTime, salesOrderStartTime, salesOrderEndTime, purchaseOrderStartTime, purchaseOrderEndTime, allowClubDiscounts, allowCouponDiscounts, allowAssociatePayments, unitOfMeasureKind == null ? null : unitOfMeasureKind.getPrimaryKey(), itemPriceType == null ? null : itemPriceType.getPrimaryKey(), cancellationPolicy == null ? null : cancellationPolicy.getPrimaryKey(), returnPolicy == null ? null : returnPolicy.getPrimaryKey(), stylePath == null ? null : stylePath.getPrimaryKey(), fromTime, thruTime); 903 } 904 905 private void bindForCreate(PreparedStatement _ps, ItemDetailValue _value) 906 throws SQLException { 907 _ps.setLong(1, _value.getEntityId()); 908 909 ItemPK itmdt_itm_itemid = _value.getItemPK(); 910 if(itmdt_itm_itemid == null) 911 _ps.setNull(2, Types.BIGINT); 912 else 913 _ps.setLong(2, itmdt_itm_itemid.getEntityId()); 914 915 String itmdt_itemname = _value.getItemName(); 916 if(itmdt_itemname == null) 917 _ps.setNull(3, Types.VARCHAR); 918 else 919 _ps.setString(3, itmdt_itemname); 920 921 ItemTypePK itmdt_ityp_itemtypeid = _value.getItemTypePK(); 922 if(itmdt_ityp_itemtypeid == null) 923 _ps.setNull(4, Types.BIGINT); 924 else 925 _ps.setLong(4, itmdt_ityp_itemtypeid.getEntityId()); 926 927 ItemUseTypePK itmdt_iutyp_itemusetypeid = _value.getItemUseTypePK(); 928 if(itmdt_iutyp_itemusetypeid == null) 929 _ps.setNull(5, Types.BIGINT); 930 else 931 _ps.setLong(5, itmdt_iutyp_itemusetypeid.getEntityId()); 932 933 ItemCategoryPK itmdt_ic_itemcategoryid = _value.getItemCategoryPK(); 934 if(itmdt_ic_itemcategoryid == null) 935 _ps.setNull(6, Types.BIGINT); 936 else 937 _ps.setLong(6, itmdt_ic_itemcategoryid.getEntityId()); 938 939 ItemAccountingCategoryPK itmdt_iactgc_itemaccountingcategoryid = _value.getItemAccountingCategoryPK(); 940 if(itmdt_iactgc_itemaccountingcategoryid == null) 941 _ps.setNull(7, Types.BIGINT); 942 else 943 _ps.setLong(7, itmdt_iactgc_itemaccountingcategoryid.getEntityId()); 944 945 ItemPurchasingCategoryPK itmdt_iprchc_itempurchasingcategoryid = _value.getItemPurchasingCategoryPK(); 946 if(itmdt_iprchc_itempurchasingcategoryid == null) 947 _ps.setNull(8, Types.BIGINT); 948 else 949 _ps.setLong(8, itmdt_iprchc_itempurchasingcategoryid.getEntityId()); 950 951 PartyPK itmdt_companypartyid = _value.getCompanyPartyPK(); 952 if(itmdt_companypartyid == null) 953 _ps.setNull(9, Types.BIGINT); 954 else 955 _ps.setLong(9, itmdt_companypartyid.getEntityId()); 956 957 ItemDeliveryTypePK itmdt_idlvrtyp_itemdeliverytypeid = _value.getItemDeliveryTypePK(); 958 if(itmdt_idlvrtyp_itemdeliverytypeid == null) 959 _ps.setNull(10, Types.BIGINT); 960 else 961 _ps.setLong(10, itmdt_idlvrtyp_itemdeliverytypeid.getEntityId()); 962 963 ItemInventoryTypePK itmdt_iinvtyp_iteminventorytypeid = _value.getItemInventoryTypePK(); 964 if(itmdt_iinvtyp_iteminventorytypeid == null) 965 _ps.setNull(11, Types.BIGINT); 966 else 967 _ps.setLong(11, itmdt_iinvtyp_iteminventorytypeid.getEntityId()); 968 969 Boolean itmdt_inventoryserialized = _value.getInventorySerialized(); 970 if(itmdt_inventoryserialized == null) 971 _ps.setNull(12, Types.BIT); 972 else 973 _ps.setInt(12, itmdt_inventoryserialized? 1: 0); 974 975 SequencePK itmdt_serialnumbersequenceid = _value.getSerialNumberSequencePK(); 976 if(itmdt_serialnumbersequenceid == null) 977 _ps.setNull(13, Types.BIGINT); 978 else 979 _ps.setLong(13, itmdt_serialnumbersequenceid.getEntityId()); 980 981 Boolean itmdt_shippingchargeexempt = _value.getShippingChargeExempt(); 982 if(itmdt_shippingchargeexempt == null) 983 _ps.setNull(14, Types.BIT); 984 else 985 _ps.setInt(14, itmdt_shippingchargeexempt? 1: 0); 986 987 Long itmdt_shippingstarttime = _value.getShippingStartTime(); 988 if(itmdt_shippingstarttime == null) 989 _ps.setNull(15, Types.BIGINT); 990 else 991 _ps.setLong(15, itmdt_shippingstarttime); 992 993 Long itmdt_shippingendtime = _value.getShippingEndTime(); 994 if(itmdt_shippingendtime == null) 995 _ps.setNull(16, Types.BIGINT); 996 else 997 _ps.setLong(16, itmdt_shippingendtime); 998 999 Long itmdt_salesorderstarttime = _value.getSalesOrderStartTime(); 1000 if(itmdt_salesorderstarttime == null) 1001 _ps.setNull(17, Types.BIGINT); 1002 else 1003 _ps.setLong(17, itmdt_salesorderstarttime); 1004 1005 Long itmdt_salesorderendtime = _value.getSalesOrderEndTime(); 1006 if(itmdt_salesorderendtime == null) 1007 _ps.setNull(18, Types.BIGINT); 1008 else 1009 _ps.setLong(18, itmdt_salesorderendtime); 1010 1011 Long itmdt_purchaseorderstarttime = _value.getPurchaseOrderStartTime(); 1012 if(itmdt_purchaseorderstarttime == null) 1013 _ps.setNull(19, Types.BIGINT); 1014 else 1015 _ps.setLong(19, itmdt_purchaseorderstarttime); 1016 1017 Long itmdt_purchaseorderendtime = _value.getPurchaseOrderEndTime(); 1018 if(itmdt_purchaseorderendtime == null) 1019 _ps.setNull(20, Types.BIGINT); 1020 else 1021 _ps.setLong(20, itmdt_purchaseorderendtime); 1022 1023 Boolean itmdt_allowclubdiscounts = _value.getAllowClubDiscounts(); 1024 if(itmdt_allowclubdiscounts == null) 1025 _ps.setNull(21, Types.BIT); 1026 else 1027 _ps.setInt(21, itmdt_allowclubdiscounts? 1: 0); 1028 1029 Boolean itmdt_allowcoupondiscounts = _value.getAllowCouponDiscounts(); 1030 if(itmdt_allowcoupondiscounts == null) 1031 _ps.setNull(22, Types.BIT); 1032 else 1033 _ps.setInt(22, itmdt_allowcoupondiscounts? 1: 0); 1034 1035 Boolean itmdt_allowassociatepayments = _value.getAllowAssociatePayments(); 1036 if(itmdt_allowassociatepayments == null) 1037 _ps.setNull(23, Types.BIT); 1038 else 1039 _ps.setInt(23, itmdt_allowassociatepayments? 1: 0); 1040 1041 UnitOfMeasureKindPK itmdt_uomk_unitofmeasurekindid = _value.getUnitOfMeasureKindPK(); 1042 if(itmdt_uomk_unitofmeasurekindid == null) 1043 _ps.setNull(24, Types.BIGINT); 1044 else 1045 _ps.setLong(24, itmdt_uomk_unitofmeasurekindid.getEntityId()); 1046 1047 ItemPriceTypePK itmdt_ipt_itempricetypeid = _value.getItemPriceTypePK(); 1048 if(itmdt_ipt_itempricetypeid == null) 1049 _ps.setNull(25, Types.BIGINT); 1050 else 1051 _ps.setLong(25, itmdt_ipt_itempricetypeid.getEntityId()); 1052 1053 CancellationPolicyPK itmdt_cnclplcy_cancellationpolicyid = _value.getCancellationPolicyPK(); 1054 if(itmdt_cnclplcy_cancellationpolicyid == null) 1055 _ps.setNull(26, Types.BIGINT); 1056 else 1057 _ps.setLong(26, itmdt_cnclplcy_cancellationpolicyid.getEntityId()); 1058 1059 ReturnPolicyPK itmdt_rtnplcy_returnpolicyid = _value.getReturnPolicyPK(); 1060 if(itmdt_rtnplcy_returnpolicyid == null) 1061 _ps.setNull(27, Types.BIGINT); 1062 else 1063 _ps.setLong(27, itmdt_rtnplcy_returnpolicyid.getEntityId()); 1064 1065 StylePathPK itmdt_stylpth_stylepathid = _value.getStylePathPK(); 1066 if(itmdt_stylpth_stylepathid == null) 1067 _ps.setNull(28, Types.BIGINT); 1068 else 1069 _ps.setLong(28, itmdt_stylpth_stylepathid.getEntityId()); 1070 1071 Long itmdt_fromtime = _value.getFromTime(); 1072 if(itmdt_fromtime == null) 1073 _ps.setNull(29, Types.BIGINT); 1074 else 1075 _ps.setLong(29, itmdt_fromtime); 1076 1077 Long itmdt_thrutime = _value.getThruTime(); 1078 if(itmdt_thrutime == null) 1079 _ps.setNull(30, Types.BIGINT); 1080 else 1081 _ps.setLong(30, itmdt_thrutime); 1082 1083 } 1084 1085 public ItemDetail create(Session session, ItemPK itemPK, String itemName, ItemTypePK itemTypePK, ItemUseTypePK itemUseTypePK, ItemCategoryPK itemCategoryPK, ItemAccountingCategoryPK itemAccountingCategoryPK, ItemPurchasingCategoryPK itemPurchasingCategoryPK, PartyPK companyPartyPK, ItemDeliveryTypePK itemDeliveryTypePK, ItemInventoryTypePK itemInventoryTypePK, Boolean inventorySerialized, SequencePK serialNumberSequencePK, Boolean shippingChargeExempt, Long shippingStartTime, Long shippingEndTime, Long salesOrderStartTime, Long salesOrderEndTime, Long purchaseOrderStartTime, Long purchaseOrderEndTime, Boolean allowClubDiscounts, Boolean allowCouponDiscounts, Boolean allowAssociatePayments, UnitOfMeasureKindPK unitOfMeasureKindPK, ItemPriceTypePK itemPriceTypePK, CancellationPolicyPK cancellationPolicyPK, ReturnPolicyPK returnPolicyPK, StylePathPK stylePathPK, Long fromTime, Long thruTime) 1086 throws PersistenceDatabaseException, PersistenceNotNullException { 1087 ItemDetailPK _pk = getNextPK(); 1088 ItemDetailValue _value = new ItemDetailValue(_pk, itemPK, itemName, itemTypePK, itemUseTypePK, itemCategoryPK, itemAccountingCategoryPK, itemPurchasingCategoryPK, companyPartyPK, itemDeliveryTypePK, itemInventoryTypePK, inventorySerialized, serialNumberSequencePK, shippingChargeExempt, shippingStartTime, shippingEndTime, salesOrderStartTime, salesOrderEndTime, purchaseOrderStartTime, purchaseOrderEndTime, allowClubDiscounts, allowCouponDiscounts, allowAssociatePayments, unitOfMeasureKindPK, itemPriceTypePK, cancellationPolicyPK, returnPolicyPK, stylePathPK, fromTime, thruTime); 1089 1090 PreparedStatement _ps = session.prepareStatement(SQL_INSERT); 1091 1092 try { 1093 bindForCreate(_ps, _value); 1094 1095 if(PersistenceDebugFlags.CheckEntityInsertRowCount) { 1096 int _count = _ps.executeUpdate(); 1097 1098 if(_count != 1) { 1099 throw new PersistenceDatabaseUpdateException("insert failed, _count = " + _count); 1100 } 1101 } else { 1102 _ps.executeUpdate(); 1103 } 1104 1105 session.getValueCache().put(_value); 1106 } catch (SQLException se) { 1107 throw new PersistenceDatabaseException(se); 1108 } 1109 1110 ItemDetail _entity = new ItemDetail(_value, EntityPermission.READ_ONLY); 1111 session.putReadOnlyEntity(_pk, _entity); 1112 1113 return _entity; 1114 } 1115 1116 public ItemDetail create(ItemPK itemPK, String itemName, ItemTypePK itemTypePK, ItemUseTypePK itemUseTypePK, ItemCategoryPK itemCategoryPK, ItemAccountingCategoryPK itemAccountingCategoryPK, ItemPurchasingCategoryPK itemPurchasingCategoryPK, PartyPK companyPartyPK, ItemDeliveryTypePK itemDeliveryTypePK, ItemInventoryTypePK itemInventoryTypePK, Boolean inventorySerialized, SequencePK serialNumberSequencePK, Boolean shippingChargeExempt, Long shippingStartTime, Long shippingEndTime, Long salesOrderStartTime, Long salesOrderEndTime, Long purchaseOrderStartTime, Long purchaseOrderEndTime, Boolean allowClubDiscounts, Boolean allowCouponDiscounts, Boolean allowAssociatePayments, UnitOfMeasureKindPK unitOfMeasureKindPK, ItemPriceTypePK itemPriceTypePK, CancellationPolicyPK cancellationPolicyPK, ReturnPolicyPK returnPolicyPK, StylePathPK stylePathPK, Long fromTime, Long thruTime) 1117 throws PersistenceDatabaseException, PersistenceNotNullException { 1118 return create(ThreadSession.currentSession(), itemPK, itemName, itemTypePK, itemUseTypePK, itemCategoryPK, itemAccountingCategoryPK, itemPurchasingCategoryPK, companyPartyPK, itemDeliveryTypePK, itemInventoryTypePK, inventorySerialized, serialNumberSequencePK, shippingChargeExempt, shippingStartTime, shippingEndTime, salesOrderStartTime, salesOrderEndTime, purchaseOrderStartTime, purchaseOrderEndTime, allowClubDiscounts, allowCouponDiscounts, allowAssociatePayments, unitOfMeasureKindPK, itemPriceTypePK, cancellationPolicyPK, returnPolicyPK, stylePathPK, fromTime, thruTime); 1119 } 1120 1121 public void create(Session session, Collection<ItemDetailValue> _values) 1122 throws PersistenceDatabaseException, PersistenceNotNullException { 1123 int _size = _values.size(); 1124 1125 if(_size > 0) { 1126 PreparedStatement _ps = session.prepareStatement(SQL_INSERT); 1127 List<ItemDetailValue> _cacheValues = new ArrayList<>(_size); 1128 1129 try { 1130 for(ItemDetailValue _value : _values) { 1131 _value.setEntityId(entityIdGenerator.getNextEntityId()); 1132 bindForCreate(_ps, _value); 1133 1134 _ps.addBatch(); 1135 1136 _cacheValues.add(_value); 1137 } 1138 1139 if(PersistenceDebugFlags.CheckEntityInsertRowCount) { 1140 int[] _counts = _ps.executeBatch(); 1141 1142 for(int _countOffset = 0 ; _countOffset < _size ; _countOffset++) { 1143 if(_counts[_countOffset] != 1 && _counts[_countOffset] != PreparedStatement.SUCCESS_NO_INFO) { 1144 throw new PersistenceDatabaseUpdateException("batch insert failed, _counts[" + _countOffset + "] = " + _counts[_countOffset]); 1145 } 1146 } 1147 } else { 1148 _ps.executeBatch(); 1149 } 1150 1151 _ps.clearBatch(); 1152 } catch (SQLException se) { 1153 throw new PersistenceDatabaseException(se); 1154 } 1155 1156 _cacheValues.forEach((_cacheValue) -> { 1157 ItemDetail _cacheEntity = new ItemDetail(_cacheValue, EntityPermission.READ_ONLY); 1158 1159 session.putReadOnlyEntity(_cacheValue.getPrimaryKey(), _cacheEntity); 1160 }); 1161 } 1162 } 1163 1164 public void create(Collection<ItemDetailValue> _values) 1165 throws PersistenceDatabaseException, PersistenceNotNullException { 1166 create(ThreadSession.currentSession(), _values); 1167 } 1168 1169 private boolean bindForStore(PreparedStatement _ps, ItemDetailValue _value) 1170 throws SQLException { 1171 boolean _hasBeenModified = _value.hasBeenModified(); 1172 1173 if(_hasBeenModified) { 1174 ItemPK itmdt_itm_itemid = _value.getItemPK(); 1175 if(itmdt_itm_itemid == null) 1176 _ps.setNull(1, Types.BIGINT); 1177 else 1178 _ps.setLong(1, itmdt_itm_itemid.getEntityId()); 1179 1180 String itmdt_itemname = _value.getItemName(); 1181 if(itmdt_itemname == null) 1182 _ps.setNull(2, Types.VARCHAR); 1183 else 1184 _ps.setString(2, itmdt_itemname); 1185 1186 ItemTypePK itmdt_ityp_itemtypeid = _value.getItemTypePK(); 1187 if(itmdt_ityp_itemtypeid == null) 1188 _ps.setNull(3, Types.BIGINT); 1189 else 1190 _ps.setLong(3, itmdt_ityp_itemtypeid.getEntityId()); 1191 1192 ItemUseTypePK itmdt_iutyp_itemusetypeid = _value.getItemUseTypePK(); 1193 if(itmdt_iutyp_itemusetypeid == null) 1194 _ps.setNull(4, Types.BIGINT); 1195 else 1196 _ps.setLong(4, itmdt_iutyp_itemusetypeid.getEntityId()); 1197 1198 ItemCategoryPK itmdt_ic_itemcategoryid = _value.getItemCategoryPK(); 1199 if(itmdt_ic_itemcategoryid == null) 1200 _ps.setNull(5, Types.BIGINT); 1201 else 1202 _ps.setLong(5, itmdt_ic_itemcategoryid.getEntityId()); 1203 1204 ItemAccountingCategoryPK itmdt_iactgc_itemaccountingcategoryid = _value.getItemAccountingCategoryPK(); 1205 if(itmdt_iactgc_itemaccountingcategoryid == null) 1206 _ps.setNull(6, Types.BIGINT); 1207 else 1208 _ps.setLong(6, itmdt_iactgc_itemaccountingcategoryid.getEntityId()); 1209 1210 ItemPurchasingCategoryPK itmdt_iprchc_itempurchasingcategoryid = _value.getItemPurchasingCategoryPK(); 1211 if(itmdt_iprchc_itempurchasingcategoryid == null) 1212 _ps.setNull(7, Types.BIGINT); 1213 else 1214 _ps.setLong(7, itmdt_iprchc_itempurchasingcategoryid.getEntityId()); 1215 1216 PartyPK itmdt_companypartyid = _value.getCompanyPartyPK(); 1217 if(itmdt_companypartyid == null) 1218 _ps.setNull(8, Types.BIGINT); 1219 else 1220 _ps.setLong(8, itmdt_companypartyid.getEntityId()); 1221 1222 ItemDeliveryTypePK itmdt_idlvrtyp_itemdeliverytypeid = _value.getItemDeliveryTypePK(); 1223 if(itmdt_idlvrtyp_itemdeliverytypeid == null) 1224 _ps.setNull(9, Types.BIGINT); 1225 else 1226 _ps.setLong(9, itmdt_idlvrtyp_itemdeliverytypeid.getEntityId()); 1227 1228 ItemInventoryTypePK itmdt_iinvtyp_iteminventorytypeid = _value.getItemInventoryTypePK(); 1229 if(itmdt_iinvtyp_iteminventorytypeid == null) 1230 _ps.setNull(10, Types.BIGINT); 1231 else 1232 _ps.setLong(10, itmdt_iinvtyp_iteminventorytypeid.getEntityId()); 1233 1234 Boolean itmdt_inventoryserialized = _value.getInventorySerialized(); 1235 if(itmdt_inventoryserialized == null) 1236 _ps.setNull(11, Types.BIT); 1237 else 1238 _ps.setInt(11, itmdt_inventoryserialized? 1: 0); 1239 1240 SequencePK itmdt_serialnumbersequenceid = _value.getSerialNumberSequencePK(); 1241 if(itmdt_serialnumbersequenceid == null) 1242 _ps.setNull(12, Types.BIGINT); 1243 else 1244 _ps.setLong(12, itmdt_serialnumbersequenceid.getEntityId()); 1245 1246 Boolean itmdt_shippingchargeexempt = _value.getShippingChargeExempt(); 1247 if(itmdt_shippingchargeexempt == null) 1248 _ps.setNull(13, Types.BIT); 1249 else 1250 _ps.setInt(13, itmdt_shippingchargeexempt? 1: 0); 1251 1252 Long itmdt_shippingstarttime = _value.getShippingStartTime(); 1253 if(itmdt_shippingstarttime == null) 1254 _ps.setNull(14, Types.BIGINT); 1255 else 1256 _ps.setLong(14, itmdt_shippingstarttime); 1257 1258 Long itmdt_shippingendtime = _value.getShippingEndTime(); 1259 if(itmdt_shippingendtime == null) 1260 _ps.setNull(15, Types.BIGINT); 1261 else 1262 _ps.setLong(15, itmdt_shippingendtime); 1263 1264 Long itmdt_salesorderstarttime = _value.getSalesOrderStartTime(); 1265 if(itmdt_salesorderstarttime == null) 1266 _ps.setNull(16, Types.BIGINT); 1267 else 1268 _ps.setLong(16, itmdt_salesorderstarttime); 1269 1270 Long itmdt_salesorderendtime = _value.getSalesOrderEndTime(); 1271 if(itmdt_salesorderendtime == null) 1272 _ps.setNull(17, Types.BIGINT); 1273 else 1274 _ps.setLong(17, itmdt_salesorderendtime); 1275 1276 Long itmdt_purchaseorderstarttime = _value.getPurchaseOrderStartTime(); 1277 if(itmdt_purchaseorderstarttime == null) 1278 _ps.setNull(18, Types.BIGINT); 1279 else 1280 _ps.setLong(18, itmdt_purchaseorderstarttime); 1281 1282 Long itmdt_purchaseorderendtime = _value.getPurchaseOrderEndTime(); 1283 if(itmdt_purchaseorderendtime == null) 1284 _ps.setNull(19, Types.BIGINT); 1285 else 1286 _ps.setLong(19, itmdt_purchaseorderendtime); 1287 1288 Boolean itmdt_allowclubdiscounts = _value.getAllowClubDiscounts(); 1289 if(itmdt_allowclubdiscounts == null) 1290 _ps.setNull(20, Types.BIT); 1291 else 1292 _ps.setInt(20, itmdt_allowclubdiscounts? 1: 0); 1293 1294 Boolean itmdt_allowcoupondiscounts = _value.getAllowCouponDiscounts(); 1295 if(itmdt_allowcoupondiscounts == null) 1296 _ps.setNull(21, Types.BIT); 1297 else 1298 _ps.setInt(21, itmdt_allowcoupondiscounts? 1: 0); 1299 1300 Boolean itmdt_allowassociatepayments = _value.getAllowAssociatePayments(); 1301 if(itmdt_allowassociatepayments == null) 1302 _ps.setNull(22, Types.BIT); 1303 else 1304 _ps.setInt(22, itmdt_allowassociatepayments? 1: 0); 1305 1306 UnitOfMeasureKindPK itmdt_uomk_unitofmeasurekindid = _value.getUnitOfMeasureKindPK(); 1307 if(itmdt_uomk_unitofmeasurekindid == null) 1308 _ps.setNull(23, Types.BIGINT); 1309 else 1310 _ps.setLong(23, itmdt_uomk_unitofmeasurekindid.getEntityId()); 1311 1312 ItemPriceTypePK itmdt_ipt_itempricetypeid = _value.getItemPriceTypePK(); 1313 if(itmdt_ipt_itempricetypeid == null) 1314 _ps.setNull(24, Types.BIGINT); 1315 else 1316 _ps.setLong(24, itmdt_ipt_itempricetypeid.getEntityId()); 1317 1318 CancellationPolicyPK itmdt_cnclplcy_cancellationpolicyid = _value.getCancellationPolicyPK(); 1319 if(itmdt_cnclplcy_cancellationpolicyid == null) 1320 _ps.setNull(25, Types.BIGINT); 1321 else 1322 _ps.setLong(25, itmdt_cnclplcy_cancellationpolicyid.getEntityId()); 1323 1324 ReturnPolicyPK itmdt_rtnplcy_returnpolicyid = _value.getReturnPolicyPK(); 1325 if(itmdt_rtnplcy_returnpolicyid == null) 1326 _ps.setNull(26, Types.BIGINT); 1327 else 1328 _ps.setLong(26, itmdt_rtnplcy_returnpolicyid.getEntityId()); 1329 1330 StylePathPK itmdt_stylpth_stylepathid = _value.getStylePathPK(); 1331 if(itmdt_stylpth_stylepathid == null) 1332 _ps.setNull(27, Types.BIGINT); 1333 else 1334 _ps.setLong(27, itmdt_stylpth_stylepathid.getEntityId()); 1335 1336 Long itmdt_fromtime = _value.getFromTime(); 1337 if(itmdt_fromtime == null) 1338 _ps.setNull(28, Types.BIGINT); 1339 else 1340 _ps.setLong(28, itmdt_fromtime); 1341 1342 Long itmdt_thrutime = _value.getThruTime(); 1343 if(itmdt_thrutime == null) 1344 _ps.setNull(29, Types.BIGINT); 1345 else 1346 _ps.setLong(29, itmdt_thrutime); 1347 1348 _ps.setLong(30, _value.getPrimaryKey().getEntityId()); 1349 1350 _value.clearHasBeenModified(); 1351 } 1352 1353 return _hasBeenModified; 1354 } 1355 1356 @Override 1357 public void store(Session session, ItemDetail entity) 1358 throws PersistenceDatabaseException { 1359 PreparedStatement _ps = session.prepareStatement(SQL_UPDATE); 1360 1361 try { 1362 ItemDetailValue _value = entity.getItemDetailValue(); 1363 1364 if(bindForStore(_ps, _value)) { 1365 if(PersistenceDebugFlags.CheckEntityUpdateRowCount) { 1366 int _count = _ps.executeUpdate(); 1367 1368 if(_count != 1) { 1369 throw new PersistenceDatabaseUpdateException("update failed, _count = " + _count); 1370 } 1371 } else { 1372 _ps.executeUpdate(); 1373 } 1374 1375 session.getValueCache().put(_value); 1376 } 1377 } catch (SQLException se) { 1378 throw new PersistenceDatabaseException(se); 1379 } 1380 } 1381 1382 @Override 1383 public void store(Session session, Collection<ItemDetail> entities) 1384 throws PersistenceDatabaseException { 1385 if(entities.size() > 0) { 1386 PreparedStatement _ps = session.prepareStatement(SQL_UPDATE); 1387 int _modifiedEntities = 0; 1388 1389 try { 1390 for(ItemDetail entity : entities) { 1391 if(bindForStore(_ps, entity.getItemDetailValue())) { 1392 _ps.addBatch(); 1393 _modifiedEntities++; 1394 } 1395 } 1396 1397 if(_modifiedEntities != 0) { 1398 if(PersistenceDebugFlags.CheckEntityUpdateRowCount) { 1399 int[] _counts = _ps.executeBatch(); 1400 1401 for(int _countOffset = 0 ; _countOffset < _modifiedEntities ; _countOffset++) { 1402 if(_counts[_countOffset] != 1 && _counts[_countOffset] != PreparedStatement.SUCCESS_NO_INFO) { 1403 throw new PersistenceDatabaseUpdateException("batch update failed, _counts[" + _countOffset + "] = " + _counts[_countOffset]); 1404 } 1405 } 1406 } else { 1407 _ps.executeBatch(); 1408 } 1409 1410 _ps.clearBatch(); 1411 1412 entities.forEach((entity) -> { 1413 session.getValueCache().put(entity.getItemDetailValue()); 1414 }); 1415 } 1416 } catch (SQLException se) { 1417 throw new PersistenceDatabaseException(se); 1418 } 1419 } 1420 } 1421 1422 @Override 1423 public void store(Collection<ItemDetail> entities) 1424 throws PersistenceDatabaseException { 1425 store(ThreadSession.currentSession(), entities); 1426 } 1427 1428 @Override 1429 public void remove(Session session, ItemDetail entity) 1430 throws PersistenceDatabaseException { 1431 remove(session, entity.getPrimaryKey()); 1432 } 1433 1434 @Override 1435 public void remove(Session session, ItemDetailPK pk) 1436 throws PersistenceDatabaseException { 1437 PreparedStatement _ps = session.prepareStatement(SQL_DELETE); 1438 long _entityId = pk.getEntityId(); 1439 1440 try { 1441 _ps.setLong(1, _entityId); 1442 1443 if(PersistenceDebugFlags.CheckEntityDeleteRowCount) { 1444 int _count = _ps.executeUpdate(); 1445 1446 if(_count != 1) { 1447 throw new PersistenceDatabaseUpdateException("remove failed, _count = " + _count); 1448 } 1449 } else { 1450 _ps.executeUpdate(); 1451 } 1452 1453 session.getValueCache().remove(pk); 1454 } catch (SQLException se) { 1455 throw new PersistenceDatabaseException(se); 1456 } 1457 1458 session.removed(pk, false); 1459 } 1460 1461 @Override 1462 public void remove(Session session, Collection<ItemDetailPK> pks) 1463 throws PersistenceDatabaseException { 1464 if(pks.size() > 0) { 1465 PreparedStatement _ps = session.prepareStatement(SQL_DELETE); 1466 int _modifiedEntities = 0; 1467 1468 try { 1469 for(ItemDetailPK pk : pks) { 1470 long _entityId = pk.getEntityId(); 1471 1472 _ps.setLong(1, _entityId); 1473 1474 _ps.addBatch(); 1475 _modifiedEntities++; 1476 } 1477 1478 if(_modifiedEntities != 0) { 1479 if(PersistenceDebugFlags.CheckEntityDeleteRowCount) { 1480 int[] _counts = _ps.executeBatch(); 1481 1482 for(int _countOffset = 0 ; _countOffset < _modifiedEntities ; _countOffset++) { 1483 if(_counts[_countOffset] != 1 && _counts[_countOffset] != PreparedStatement.SUCCESS_NO_INFO) { 1484 throw new PersistenceDatabaseUpdateException("batch remove failed, _counts[" + _countOffset + "] = " + _counts[_countOffset]); 1485 } 1486 } 1487 } else { 1488 _ps.executeBatch(); 1489 } 1490 1491 _ps.clearBatch(); 1492 1493 pks.forEach((pk) -> { 1494 session.getValueCache().remove(pk); 1495 }); 1496 } 1497 } catch (SQLException se) { 1498 throw new PersistenceDatabaseException(se); 1499 } 1500 1501 pks.forEach((pk) -> { 1502 session.removed(pk, true); 1503 }); 1504 } 1505 } 1506 1507 @Override 1508 public void remove(Collection<ItemDetailPK> pks) 1509 throws PersistenceDatabaseException { 1510 remove(ThreadSession.currentSession(), pks); 1511 } 1512 1513 @Override 1514 public boolean validPK(Session session, ItemDetailPK pk) 1515 throws PersistenceDatabaseException { 1516 boolean valid = false; 1517 PreparedStatement _ps = session.prepareStatement(SQL_VALID); 1518 ResultSet _rs = null; 1519 1520 try { 1521 _ps.setLong(1, pk.getEntityId()); 1522 1523 _rs = _ps.executeQuery(); 1524 if(_rs.next()) { 1525 long _count = _rs.getLong(1); 1526 if(_rs.wasNull()) 1527 _count = 0; 1528 1529 if(_count == 1) 1530 valid = true; 1531 } 1532 } catch (SQLException se) { 1533 throw new PersistenceDatabaseException(se); 1534 } finally { 1535 if(_rs != null) { 1536 try { 1537 _rs.close(); 1538 } catch (SQLException se) { 1539 // do nothing 1540 } 1541 } 1542 } 1543 1544 return valid; 1545 } 1546 1547}