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