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