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