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 * PaymentProcessorActionFactory.java 021 */ 022 023package com.echothree.model.data.payment.server.factory; 024 025import com.echothree.model.data.payment.common.pk.PaymentProcessorPK; 026import com.echothree.model.data.payment.common.pk.PaymentProcessorTypeActionPK; 027 028import com.echothree.model.data.payment.server.entity.PaymentProcessor; 029import com.echothree.model.data.payment.server.entity.PaymentProcessorTypeAction; 030 031import com.echothree.model.data.payment.common.PaymentProcessorActionConstants; 032import com.echothree.model.data.payment.common.pk.PaymentProcessorActionPK; 033import com.echothree.model.data.payment.server.value.PaymentProcessorActionValue; 034import com.echothree.model.data.payment.server.entity.PaymentProcessorAction; 035import com.echothree.util.common.exception.PersistenceDatabaseException; 036import com.echothree.util.common.exception.PersistenceDatabaseUpdateException; 037import com.echothree.util.common.exception.PersistenceNotNullException; 038import com.echothree.util.server.persistence.BaseFactory; 039import com.echothree.util.server.persistence.EntityIdGenerator; 040import com.echothree.util.server.persistence.EntityPermission; 041import com.echothree.util.server.persistence.PersistenceDebugFlags; 042import com.echothree.util.server.persistence.Session; 043import java.sql.PreparedStatement; 044import java.sql.ResultSet; 045import java.sql.SQLException; 046import java.sql.Types; 047import java.io.ByteArrayInputStream; 048import java.io.StringReader; 049import java.util.ArrayList; 050import java.util.Collection; 051import java.util.HashSet; 052import java.util.List; 053import java.util.Map; 054import java.util.Set; 055import javax.enterprise.context.ApplicationScoped; 056import javax.enterprise.inject.spi.CDI; 057import javax.inject.Inject; 058import org.jooq.ResultQuery; 059import org.slf4j.Logger; 060import org.slf4j.LoggerFactory; 061 062@ApplicationScoped 063public class PaymentProcessorActionFactory 064 implements BaseFactory<PaymentProcessorActionPK, PaymentProcessorAction> { 065 066 @Inject 067 Session session; 068 069 //private static final Logger log = LoggerFactory.getLogger(PaymentProcessorActionFactory.class); 070 071 final private static String SQL_SELECT_READ_ONLY = "SELECT pprcact_paymentprocessoractionid, pprcact_pprc_paymentprocessorid, pprcact_pprctypact_paymentprocessortypeactionid, pprcact_fromtime, pprcact_thrutime FROM paymentprocessoractions WHERE pprcact_paymentprocessoractionid = ?"; 072 final private static String SQL_SELECT_READ_WRITE = "SELECT pprcact_paymentprocessoractionid, pprcact_pprc_paymentprocessorid, pprcact_pprctypact_paymentprocessortypeactionid, pprcact_fromtime, pprcact_thrutime FROM paymentprocessoractions WHERE pprcact_paymentprocessoractionid = ? FOR UPDATE"; 073 final private static String SQL_INSERT = "INSERT INTO paymentprocessoractions (pprcact_paymentprocessoractionid, pprcact_pprc_paymentprocessorid, pprcact_pprctypact_paymentprocessortypeactionid, pprcact_fromtime, pprcact_thrutime) VALUES (?, ?, ?, ?, ?)"; 074 final private static String SQL_UPDATE = "UPDATE paymentprocessoractions SET pprcact_pprc_paymentprocessorid = ?, pprcact_pprctypact_paymentprocessortypeactionid = ?, pprcact_fromtime = ?, pprcact_thrutime = ? WHERE pprcact_paymentprocessoractionid = ?"; 075 final private static String SQL_DELETE = "DELETE FROM paymentprocessoractions WHERE pprcact_paymentprocessoractionid = ?"; 076 final private static String SQL_VALID = "SELECT COUNT(*) FROM paymentprocessoractions WHERE pprcact_paymentprocessoractionid = ?"; 077 078 final private static String PK_COLUMN = "pprcact_paymentprocessoractionid"; 079 final private static String ALL_COLUMNS = "pprcact_paymentprocessoractionid, pprcact_pprc_paymentprocessorid, pprcact_pprctypact_paymentprocessortypeactionid, pprcact_fromtime, pprcact_thrutime"; 080 final public static String TABLE_NAME = "paymentprocessoractions"; 081 082 final public static String PPRCACT_PAYMENTPROCESSORACTIONID = "pprcact_paymentprocessoractionid"; 083 final public static String PPRCACT_PPRC_PAYMENTPROCESSORID = "pprcact_pprc_paymentprocessorid"; 084 final public static String PPRCACT_PPRCTYPACT_PAYMENTPROCESSORTYPEACTIONID = "pprcact_pprctypact_paymentprocessortypeactionid"; 085 final public static String PPRCACT_FROMTIME = "pprcact_fromtime"; 086 final public static String PPRCACT_THRUTIME = "pprcact_thrutime"; 087 088 final private static EntityIdGenerator entityIdGenerator = new EntityIdGenerator(PaymentProcessorActionConstants.COMPONENT_VENDOR_NAME, PaymentProcessorActionConstants.ENTITY_TYPE_NAME); 089 090 /** Creates a new instance of PaymentProcessorActionFactory */ 091 protected PaymentProcessorActionFactory() { 092 super(); 093 } 094 095 public static PaymentProcessorActionFactory getInstance() { 096 return CDI.current().select(PaymentProcessorActionFactory.class).get(); 097 } 098 099 @Override 100 public String getPKColumn() { 101 return PK_COLUMN; 102 } 103 104 @Override 105 public String getAllColumns() { 106 return ALL_COLUMNS; 107 } 108 109 @Override 110 public String getTableName() { 111 return TABLE_NAME; 112 } 113 114 @Override 115 public String getComponentVendorName() { 116 return PaymentProcessorActionConstants.COMPONENT_VENDOR_NAME; 117 } 118 119 @Override 120 public String getEntityTypeName() { 121 return PaymentProcessorActionConstants.ENTITY_TYPE_NAME; 122 } 123 124 public PreparedStatement prepareStatement(String query) { 125 return session.prepareStatement(PaymentProcessorActionFactory.class, query); 126 } 127 128 public PaymentProcessorActionPK getNextPK() { 129 return new PaymentProcessorActionPK(entityIdGenerator.getNextEntityId()); 130 } 131 132 public Set<PaymentProcessorActionPK> getPKsFromResultSetAsSet(ResultSet rs) 133 throws PersistenceDatabaseException { 134 Set<PaymentProcessorActionPK> _result = new HashSet<>(); 135 136 try { 137 while(rs.next()) { 138 _result.add(getPKFromResultSet(rs)); 139 } 140 } catch (SQLException se) { 141 throw new PersistenceDatabaseException(se); 142 } 143 144 return _result; 145 } 146 147 public java.util.List<PaymentProcessorActionPK> getPKsFromResultSetAsList(ResultSet rs) 148 throws PersistenceDatabaseException { 149 java.util.List<PaymentProcessorActionPK> _result = new ArrayList<>(); 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 PaymentProcessorActionPK getPKFromResultSet(ResultSet rs) 163 throws PersistenceDatabaseException { 164 PaymentProcessorActionPK _result; 165 166 try { 167 long pprcact_paymentprocessoractionid = rs.getLong(PPRCACT_PAYMENTPROCESSORACTIONID); 168 Long _entityId = rs.wasNull() ? null : pprcact_paymentprocessoractionid; 169 170 _result = new PaymentProcessorActionPK(_entityId); 171 } catch (SQLException se) { 172 throw new PersistenceDatabaseException(se); 173 } 174 175 return _result; 176 } 177 178 public java.util.List<PaymentProcessorActionValue> getValuesFromPKs(Collection<PaymentProcessorActionPK> pks) 179 throws PersistenceDatabaseException { 180 java.util.List<PaymentProcessorActionValue> _values = new ArrayList<>(pks.size()); 181 182 for(PaymentProcessorActionPK _pk: pks) { 183 _values.add(getValueFromPK(_pk)); 184 } 185 186 return _values; 187 } 188 189 public PaymentProcessorActionValue getValueFromPK(PaymentProcessorActionPK pk) 190 throws PersistenceDatabaseException { 191 PaymentProcessorActionValue _value; 192 193 // See if we already have the entity in the session cache 194 PaymentProcessorAction _entity = (PaymentProcessorAction)session.getEntity(pk); 195 if(_entity == null) 196 _value = getEntityFromPK(EntityPermission.READ_ONLY, pk).getPaymentProcessorActionValue(); 197 else 198 _value = _entity.getPaymentProcessorActionValue(); 199 200 return _value; 201 } 202 203 public java.util.List<PaymentProcessorActionValue> getValuesFromResultSet(ResultSet rs) 204 throws PersistenceDatabaseException { 205 java.util.List<PaymentProcessorActionValue> _result = new ArrayList<>(); 206 207 try { 208 while(rs.next()) { 209 _result.add(getValueFromResultSet(rs)); 210 } 211 } catch (SQLException se) { 212 throw new PersistenceDatabaseException(se); 213 } 214 215 return _result; 216 } 217 218 public PaymentProcessorActionValue getValueFromResultSet(ResultSet rs) 219 throws PersistenceDatabaseException { 220 PaymentProcessorActionValue _value; 221 222 try { 223 Long pprcact_paymentprocessoractionid = rs.getLong(PPRCACT_PAYMENTPROCESSORACTIONID); 224 PaymentProcessorActionPK _pk = new PaymentProcessorActionPK(pprcact_paymentprocessoractionid); 225 226 // See if we already have the entity in the session cache 227 PaymentProcessorAction _entity = (PaymentProcessorAction)session.getEntity(_pk); 228 229 if(_entity == null) { 230 Long pprcact_pprc_paymentprocessorid = rs.getLong(PPRCACT_PPRC_PAYMENTPROCESSORID); 231 if(rs.wasNull()) 232 pprcact_pprc_paymentprocessorid = null; 233 234 Long pprcact_pprctypact_paymentprocessortypeactionid = rs.getLong(PPRCACT_PPRCTYPACT_PAYMENTPROCESSORTYPEACTIONID); 235 if(rs.wasNull()) 236 pprcact_pprctypact_paymentprocessortypeactionid = null; 237 238 Long pprcact_fromtime = rs.getLong(PPRCACT_FROMTIME); 239 if(rs.wasNull()) 240 pprcact_fromtime = null; 241 242 Long pprcact_thrutime = rs.getLong(PPRCACT_THRUTIME); 243 if(rs.wasNull()) 244 pprcact_thrutime = null; 245 246 _value = new PaymentProcessorActionValue(_pk, new PaymentProcessorPK(pprcact_pprc_paymentprocessorid), new PaymentProcessorTypeActionPK(pprcact_pprctypact_paymentprocessortypeactionid), pprcact_fromtime, pprcact_thrutime); 247 } else 248 _value = _entity.getPaymentProcessorActionValue(); 249 } catch (SQLException se) { 250 throw new PersistenceDatabaseException(se); 251 } 252 253 return _value; 254 } 255 256 public java.util.List<PaymentProcessorAction> getEntitiesFromPKs(EntityPermission entityPermission, Collection<PaymentProcessorActionPK> pks) 257 throws PersistenceDatabaseException { 258 java.util.List<PaymentProcessorAction> _entities = new ArrayList<>(pks.size()); 259 260 for(PaymentProcessorActionPK _pk: pks) { 261 _entities.add(getEntityFromPK(entityPermission, _pk)); 262 } 263 264 return _entities; 265 } 266 267 public PaymentProcessorAction getEntityFromValue(EntityPermission entityPermission, PaymentProcessorActionValue value) { 268 return getEntityFromPK(entityPermission, value.getPrimaryKey()); 269 } 270 271 public PaymentProcessorAction getEntityFromCache(PaymentProcessorActionPK pk) { 272 PaymentProcessorActionValue _value = (PaymentProcessorActionValue)session.getValueCache().get(pk); 273 274 return _value == null ? null : new PaymentProcessorAction(_value, EntityPermission.READ_ONLY); 275 } 276 277 public PaymentProcessorAction getEntityFromPK(EntityPermission entityPermission, PaymentProcessorActionPK pk) 278 throws PersistenceDatabaseException { 279 PaymentProcessorAction _entity; 280 281 // See if we already have the entity in the session cache 282 _entity = (PaymentProcessorAction)session.getEntity(pk); 283 if(_entity != null) { 284 // If the requested permission is READ_WRITE, and the cached permission is 285 // READ_ONLY, then pretend that the cached object wasn't found, and create 286 // a new entity that is READ_WRITE. 287 if(entityPermission.equals(EntityPermission.READ_WRITE)) { 288 if(_entity.getEntityPermission().equals(EntityPermission.READ_ONLY)) 289 _entity = null; 290 } 291 } 292 293 if(_entity == null && entityPermission.equals(EntityPermission.READ_ONLY)) { 294 _entity = getEntityFromCache(pk); 295 } 296 297 if(_entity == null) { 298 PreparedStatement _ps = session.prepareStatement(entityPermission.equals(EntityPermission.READ_ONLY)? SQL_SELECT_READ_ONLY: SQL_SELECT_READ_WRITE); 299 long _entityId = pk.getEntityId(); 300 ResultSet _rs = null; 301 302 try { 303 _ps.setLong(1, _entityId); 304 _rs = _ps.executeQuery(); 305 if(_rs.next()) { 306 _entity = getEntityFromResultSet(entityPermission, _rs); 307 } 308 } catch (SQLException se) { 309 throw new PersistenceDatabaseException(se); 310 } finally { 311 if(_rs != null) { 312 try { 313 _rs.close(); 314 } catch (SQLException se) { 315 // do nothing 316 } 317 } 318 } 319 } 320 321 return _entity; 322 } 323 324 public Set<PaymentProcessorActionPK> getPKsFromQueryAsSet(PreparedStatement ps, final Object... params) 325 throws PersistenceDatabaseException { 326 Set<PaymentProcessorActionPK> _pks; 327 ResultSet _rs = null; 328 329 try { 330 if(params.length != 0) { 331 Session.setQueryParams(ps, params); 332 } 333 334 _rs = ps.executeQuery(); 335 _pks = getPKsFromResultSetAsSet(_rs); 336 _rs.close(); 337 } catch (SQLException se) { 338 throw new PersistenceDatabaseException(se); 339 } finally { 340 if(_rs != null) { 341 try { 342 _rs.close(); 343 } catch (SQLException se) { 344 // do nothing 345 } 346 } 347 } 348 349 return _pks; 350 } 351 352 public java.util.List<PaymentProcessorActionPK> getPKsFromQueryAsList(PreparedStatement ps, final Object... params) 353 throws PersistenceDatabaseException { 354 java.util.List<PaymentProcessorActionPK> _pks; 355 ResultSet _rs = null; 356 357 try { 358 if(params.length != 0) { 359 Session.setQueryParams(ps, params); 360 } 361 362 _rs = ps.executeQuery(); 363 _pks = getPKsFromResultSetAsList(_rs); 364 _rs.close(); 365 } catch (SQLException se) { 366 throw new PersistenceDatabaseException(se); 367 } finally { 368 if(_rs != null) { 369 try { 370 _rs.close(); 371 } catch (SQLException se) { 372 // do nothing 373 } 374 } 375 } 376 377 return _pks; 378 } 379 380 public PaymentProcessorActionPK getPKFromQuery(PreparedStatement ps, final Object... params) 381 throws PersistenceDatabaseException { 382 PaymentProcessorActionPK _pk = null; 383 ResultSet _rs = null; 384 385 try { 386 if(params.length != 0) { 387 Session.setQueryParams(ps, params); 388 } 389 390 _rs = ps.executeQuery(); 391 if(_rs.next()) { 392 _pk = getPKFromResultSet(_rs); 393 } 394 _rs.close(); 395 } catch (SQLException se) { 396 throw new PersistenceDatabaseException(se); 397 } finally { 398 if(_rs != null) { 399 try { 400 _rs.close(); 401 } catch (SQLException se) { 402 // do nothing 403 } 404 } 405 } 406 407 return _pk; 408 } 409 410 public java.util.List<PaymentProcessorAction> getEntitiesFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap, final Object... params) 411 throws PersistenceDatabaseException { 412 PreparedStatement ps = session.prepareStatement(PaymentProcessorActionFactory.class, queryMap.get(entityPermission)); 413 414 return getEntitiesFromQuery(entityPermission, ps, params); 415 } 416 417 public java.util.List<PaymentProcessorAction> getEntitiesFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap) 418 throws PersistenceDatabaseException { 419 PreparedStatement ps = session.prepareStatement(PaymentProcessorActionFactory.class, queryMap.get(entityPermission)); 420 421 return getEntitiesFromQuery(entityPermission, ps); 422 } 423 424 public java.util.List<PaymentProcessorAction> getEntitiesFromQuery(EntityPermission entityPermission, ResultQuery<?> query) 425 throws PersistenceDatabaseException { 426 PreparedStatement ps = session.prepareStatement(PaymentProcessorActionFactory.class, query.getSQL()); 427 428 return getEntitiesFromQuery(entityPermission, ps, query.getBindValues().toArray()); 429 } 430 431 public java.util.List<PaymentProcessorAction> getEntitiesFromQuery(EntityPermission entityPermission, PreparedStatement ps, final Object... params) 432 throws PersistenceDatabaseException { 433 java.util.List<PaymentProcessorAction> _entities; 434 ResultSet _rs = null; 435 436 try { 437 if(params.length != 0) { 438 Session.setQueryParams(ps, params); 439 } 440 441 _rs = ps.executeQuery(); 442 _entities = getEntitiesFromResultSet(entityPermission, _rs); 443 _rs.close(); 444 } catch (SQLException se) { 445 throw new PersistenceDatabaseException(se); 446 } finally { 447 if(_rs != null) { 448 try { 449 _rs.close(); 450 } catch (SQLException se) { 451 // do nothing 452 } 453 } 454 } 455 456 return _entities; 457 } 458 459 public PaymentProcessorAction getEntityFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap, final Object... params) 460 throws PersistenceDatabaseException { 461 PreparedStatement ps = session.prepareStatement(PaymentProcessorActionFactory.class, queryMap.get(entityPermission)); 462 463 return getEntityFromQuery(entityPermission, ps, params); 464 } 465 466 public PaymentProcessorAction getEntityFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap) 467 throws PersistenceDatabaseException { 468 PreparedStatement ps = session.prepareStatement(PaymentProcessorActionFactory.class, queryMap.get(entityPermission)); 469 470 return getEntityFromQuery(entityPermission, ps); 471 } 472 473 public PaymentProcessorAction getEntityFromQuery(EntityPermission entityPermission, ResultQuery<?> query) 474 throws PersistenceDatabaseException { 475 PreparedStatement ps = session.prepareStatement(PaymentProcessorActionFactory.class, query.getSQL()); 476 477 return getEntityFromQuery(entityPermission, ps, query.getBindValues().toArray()); 478 } 479 480 public PaymentProcessorAction getEntityFromQuery(EntityPermission entityPermission, PreparedStatement ps, final Object... params) 481 throws PersistenceDatabaseException { 482 PaymentProcessorAction _entity = null; 483 ResultSet _rs = null; 484 485 try { 486 if(params.length != 0) { 487 Session.setQueryParams(ps, params); 488 } 489 490 _rs = ps.executeQuery(); 491 if(_rs.next()) { 492 _entity = getEntityFromResultSet(entityPermission, _rs); 493 } 494 _rs.close(); 495 } catch (SQLException se) { 496 throw new PersistenceDatabaseException(se); 497 } finally { 498 if(_rs != null) { 499 try { 500 _rs.close(); 501 } catch (SQLException se) { 502 // do nothing 503 } 504 } 505 } 506 507 return _entity; 508 } 509 510 public java.util.List<PaymentProcessorAction> getEntitiesFromResultSet(EntityPermission entityPermission, ResultSet rs) 511 throws PersistenceDatabaseException { 512 java.util.List<PaymentProcessorAction> _result = new ArrayList<>(); 513 514 try { 515 while(rs.next()) { 516 _result.add(getEntityFromResultSet(entityPermission, rs)); 517 } 518 } catch (SQLException se) { 519 throw new PersistenceDatabaseException(se); 520 } 521 522 return _result; 523 } 524 525 public PaymentProcessorAction getEntityFromResultSet(EntityPermission entityPermission, ResultSet rs) 526 throws PersistenceDatabaseException { 527 PaymentProcessorAction _entity; 528 529 try { 530 Long pprcact_paymentprocessoractionid = rs.getLong(PPRCACT_PAYMENTPROCESSORACTIONID); 531 PaymentProcessorActionPK _pk = new PaymentProcessorActionPK(pprcact_paymentprocessoractionid); 532 533 // See if we already have the entity in the session cache 534 _entity = (PaymentProcessorAction)session.getEntity(_pk); 535 if(_entity != null) { 536 // If the requested permission is READ_WRITE, and the cached permission is 537 // READ_ONLY, then pretend that the cached object wasn't found, and create 538 // a new entity that is READ_WRITE. 539 if(entityPermission.equals(EntityPermission.READ_WRITE)) { 540 if(_entity.getEntityPermission().equals(EntityPermission.READ_ONLY)) 541 _entity = null; 542 } 543 } 544 boolean foundInSessionCache = _entity != null; 545 546 if(_entity == null && entityPermission.equals(EntityPermission.READ_ONLY)) { 547 _entity = getEntityFromCache(_pk); 548 } 549 550 if(_entity == null) { 551 Long pprcact_pprc_paymentprocessorid = rs.getLong(PPRCACT_PPRC_PAYMENTPROCESSORID); 552 if(rs.wasNull()) 553 pprcact_pprc_paymentprocessorid = null; 554 555 Long pprcact_pprctypact_paymentprocessortypeactionid = rs.getLong(PPRCACT_PPRCTYPACT_PAYMENTPROCESSORTYPEACTIONID); 556 if(rs.wasNull()) 557 pprcact_pprctypact_paymentprocessortypeactionid = null; 558 559 Long pprcact_fromtime = rs.getLong(PPRCACT_FROMTIME); 560 if(rs.wasNull()) 561 pprcact_fromtime = null; 562 563 Long pprcact_thrutime = rs.getLong(PPRCACT_THRUTIME); 564 if(rs.wasNull()) 565 pprcact_thrutime = null; 566 567 PaymentProcessorActionValue _value = new PaymentProcessorActionValue(_pk, pprcact_pprc_paymentprocessorid == null? null: new PaymentProcessorPK(pprcact_pprc_paymentprocessorid), pprcact_pprctypact_paymentprocessortypeactionid == null? null: new PaymentProcessorTypeActionPK(pprcact_pprctypact_paymentprocessortypeactionid), pprcact_fromtime, pprcact_thrutime); 568 _entity = new PaymentProcessorAction(_value, entityPermission); 569 } 570 571 if(!foundInSessionCache) { 572 if(entityPermission.equals(EntityPermission.READ_ONLY)) { 573 session.putReadOnlyEntity(_pk, _entity); 574 session.getValueCache().put(_entity.getPaymentProcessorActionValue()); 575 } else { 576 session.putReadWriteEntity(_pk, _entity); 577 } 578 } 579 } catch (SQLException se) { 580 throw new PersistenceDatabaseException(se); 581 } 582 583 return _entity; 584 } 585 586 public PaymentProcessorAction create(PaymentProcessor paymentProcessor, PaymentProcessorTypeAction paymentProcessorTypeAction, Long fromTime, Long thruTime) 587 throws PersistenceDatabaseException, PersistenceNotNullException { 588 return create(paymentProcessor == null ? null : paymentProcessor.getPrimaryKey(), paymentProcessorTypeAction == null ? null : paymentProcessorTypeAction.getPrimaryKey(), fromTime, thruTime); 589 } 590 591 private void bindForCreate(PreparedStatement _ps, PaymentProcessorActionValue _value) 592 throws SQLException { 593 _ps.setLong(1, _value.getEntityId()); 594 595 PaymentProcessorPK pprcact_pprc_paymentprocessorid = _value.getPaymentProcessorPK(); 596 if(pprcact_pprc_paymentprocessorid == null) 597 _ps.setNull(2, Types.BIGINT); 598 else 599 _ps.setLong(2, pprcact_pprc_paymentprocessorid.getEntityId()); 600 601 PaymentProcessorTypeActionPK pprcact_pprctypact_paymentprocessortypeactionid = _value.getPaymentProcessorTypeActionPK(); 602 if(pprcact_pprctypact_paymentprocessortypeactionid == null) 603 _ps.setNull(3, Types.BIGINT); 604 else 605 _ps.setLong(3, pprcact_pprctypact_paymentprocessortypeactionid.getEntityId()); 606 607 Long pprcact_fromtime = _value.getFromTime(); 608 if(pprcact_fromtime == null) 609 _ps.setNull(4, Types.BIGINT); 610 else 611 _ps.setLong(4, pprcact_fromtime); 612 613 Long pprcact_thrutime = _value.getThruTime(); 614 if(pprcact_thrutime == null) 615 _ps.setNull(5, Types.BIGINT); 616 else 617 _ps.setLong(5, pprcact_thrutime); 618 619 } 620 621 public PaymentProcessorAction create(PaymentProcessorPK paymentProcessorPK, PaymentProcessorTypeActionPK paymentProcessorTypeActionPK, Long fromTime, Long thruTime) 622 throws PersistenceDatabaseException, PersistenceNotNullException { 623 PaymentProcessorActionPK _pk = getNextPK(); 624 PaymentProcessorActionValue _value = new PaymentProcessorActionValue(_pk, paymentProcessorPK, paymentProcessorTypeActionPK, fromTime, thruTime); 625 626 PreparedStatement _ps = session.prepareStatement(SQL_INSERT); 627 628 try { 629 bindForCreate(_ps, _value); 630 631 if(PersistenceDebugFlags.CheckEntityInsertRowCount) { 632 int _count = _ps.executeUpdate(); 633 634 if(_count != 1) { 635 throw new PersistenceDatabaseUpdateException("insert failed, _count = " + _count); 636 } 637 } else { 638 _ps.executeUpdate(); 639 } 640 641 session.getValueCache().put(_value); 642 } catch (SQLException se) { 643 throw new PersistenceDatabaseException(se); 644 } 645 646 PaymentProcessorAction _entity = new PaymentProcessorAction(_value, EntityPermission.READ_ONLY); 647 session.putReadOnlyEntity(_pk, _entity); 648 649 return _entity; 650 } 651 652 public void create(Collection<PaymentProcessorActionValue> _values) 653 throws PersistenceDatabaseException, PersistenceNotNullException { 654 int _size = _values.size(); 655 656 if(_size > 0) { 657 PreparedStatement _ps = session.prepareStatement(SQL_INSERT); 658 List<PaymentProcessorActionValue> _cacheValues = new ArrayList<>(_size); 659 660 try { 661 for(PaymentProcessorActionValue _value : _values) { 662 _value.setEntityId(entityIdGenerator.getNextEntityId()); 663 bindForCreate(_ps, _value); 664 665 _ps.addBatch(); 666 667 _cacheValues.add(_value); 668 } 669 670 if(PersistenceDebugFlags.CheckEntityInsertRowCount) { 671 int[] _counts = _ps.executeBatch(); 672 673 for(int _countOffset = 0 ; _countOffset < _size ; _countOffset++) { 674 if(_counts[_countOffset] != 1 && _counts[_countOffset] != PreparedStatement.SUCCESS_NO_INFO) { 675 throw new PersistenceDatabaseUpdateException("batch insert failed, _counts[" + _countOffset + "] = " + _counts[_countOffset]); 676 } 677 } 678 } else { 679 _ps.executeBatch(); 680 } 681 682 _ps.clearBatch(); 683 } catch (SQLException se) { 684 throw new PersistenceDatabaseException(se); 685 } 686 687 _cacheValues.forEach((_cacheValue) -> { 688 PaymentProcessorAction _cacheEntity = new PaymentProcessorAction(_cacheValue, EntityPermission.READ_ONLY); 689 690 session.putReadOnlyEntity(_cacheValue.getPrimaryKey(), _cacheEntity); 691 }); 692 } 693 } 694 695 private boolean bindForStore(PreparedStatement _ps, PaymentProcessorActionValue _value) 696 throws SQLException { 697 boolean _hasBeenModified = _value.hasBeenModified(); 698 699 if(_hasBeenModified) { 700 PaymentProcessorPK pprcact_pprc_paymentprocessorid = _value.getPaymentProcessorPK(); 701 if(pprcact_pprc_paymentprocessorid == null) 702 _ps.setNull(1, Types.BIGINT); 703 else 704 _ps.setLong(1, pprcact_pprc_paymentprocessorid.getEntityId()); 705 706 PaymentProcessorTypeActionPK pprcact_pprctypact_paymentprocessortypeactionid = _value.getPaymentProcessorTypeActionPK(); 707 if(pprcact_pprctypact_paymentprocessortypeactionid == null) 708 _ps.setNull(2, Types.BIGINT); 709 else 710 _ps.setLong(2, pprcact_pprctypact_paymentprocessortypeactionid.getEntityId()); 711 712 Long pprcact_fromtime = _value.getFromTime(); 713 if(pprcact_fromtime == null) 714 _ps.setNull(3, Types.BIGINT); 715 else 716 _ps.setLong(3, pprcact_fromtime); 717 718 Long pprcact_thrutime = _value.getThruTime(); 719 if(pprcact_thrutime == null) 720 _ps.setNull(4, Types.BIGINT); 721 else 722 _ps.setLong(4, pprcact_thrutime); 723 724 _ps.setLong(5, _value.getPrimaryKey().getEntityId()); 725 726 _value.clearHasBeenModified(); 727 } 728 729 return _hasBeenModified; 730 } 731 732 @Override 733 public void store(PaymentProcessorAction entity) 734 throws PersistenceDatabaseException { 735 PreparedStatement _ps = session.prepareStatement(SQL_UPDATE); 736 737 try { 738 PaymentProcessorActionValue _value = entity.getPaymentProcessorActionValue(); 739 740 if(bindForStore(_ps, _value)) { 741 if(PersistenceDebugFlags.CheckEntityUpdateRowCount) { 742 int _count = _ps.executeUpdate(); 743 744 if(_count != 1) { 745 throw new PersistenceDatabaseUpdateException("update failed, _count = " + _count); 746 } 747 } else { 748 _ps.executeUpdate(); 749 } 750 751 session.getValueCache().put(_value); 752 } 753 } catch (SQLException se) { 754 throw new PersistenceDatabaseException(se); 755 } 756 } 757 758 @Override 759 public void store(Collection<PaymentProcessorAction> entities) 760 throws PersistenceDatabaseException { 761 if(entities.size() > 0) { 762 PreparedStatement _ps = session.prepareStatement(SQL_UPDATE); 763 int _modifiedEntities = 0; 764 765 try { 766 for(PaymentProcessorAction entity : entities) { 767 if(bindForStore(_ps, entity.getPaymentProcessorActionValue())) { 768 _ps.addBatch(); 769 _modifiedEntities++; 770 } 771 } 772 773 if(_modifiedEntities != 0) { 774 if(PersistenceDebugFlags.CheckEntityUpdateRowCount) { 775 int[] _counts = _ps.executeBatch(); 776 777 for(int _countOffset = 0 ; _countOffset < _modifiedEntities ; _countOffset++) { 778 if(_counts[_countOffset] != 1 && _counts[_countOffset] != PreparedStatement.SUCCESS_NO_INFO) { 779 throw new PersistenceDatabaseUpdateException("batch update failed, _counts[" + _countOffset + "] = " + _counts[_countOffset]); 780 } 781 } 782 } else { 783 _ps.executeBatch(); 784 } 785 786 _ps.clearBatch(); 787 788 entities.forEach((entity) -> { 789 session.getValueCache().put(entity.getPaymentProcessorActionValue()); 790 }); 791 } 792 } catch (SQLException se) { 793 throw new PersistenceDatabaseException(se); 794 } 795 } 796 } 797 798 @Override 799 public void remove(PaymentProcessorAction entity) 800 throws PersistenceDatabaseException { 801 remove(entity.getPrimaryKey()); 802 } 803 804 @Override 805 public void remove(PaymentProcessorActionPK pk) 806 throws PersistenceDatabaseException { 807 PreparedStatement _ps = session.prepareStatement(SQL_DELETE); 808 long _entityId = pk.getEntityId(); 809 810 try { 811 _ps.setLong(1, _entityId); 812 813 if(PersistenceDebugFlags.CheckEntityDeleteRowCount) { 814 int _count = _ps.executeUpdate(); 815 816 if(_count != 1) { 817 throw new PersistenceDatabaseUpdateException("remove failed, _count = " + _count); 818 } 819 } else { 820 _ps.executeUpdate(); 821 } 822 823 session.getValueCache().remove(pk); 824 } catch (SQLException se) { 825 throw new PersistenceDatabaseException(se); 826 } 827 828 session.removed(pk, false); 829 } 830 831 @Override 832 public void remove(Collection<PaymentProcessorActionPK> pks) 833 throws PersistenceDatabaseException { 834 if(pks.size() > 0) { 835 PreparedStatement _ps = session.prepareStatement(SQL_DELETE); 836 int _modifiedEntities = 0; 837 838 try { 839 for(PaymentProcessorActionPK pk : pks) { 840 long _entityId = pk.getEntityId(); 841 842 _ps.setLong(1, _entityId); 843 844 _ps.addBatch(); 845 _modifiedEntities++; 846 } 847 848 if(_modifiedEntities != 0) { 849 if(PersistenceDebugFlags.CheckEntityDeleteRowCount) { 850 int[] _counts = _ps.executeBatch(); 851 852 for(int _countOffset = 0 ; _countOffset < _modifiedEntities ; _countOffset++) { 853 if(_counts[_countOffset] != 1 && _counts[_countOffset] != PreparedStatement.SUCCESS_NO_INFO) { 854 throw new PersistenceDatabaseUpdateException("batch remove failed, _counts[" + _countOffset + "] = " + _counts[_countOffset]); 855 } 856 } 857 } else { 858 _ps.executeBatch(); 859 } 860 861 _ps.clearBatch(); 862 863 pks.forEach((pk) -> { 864 session.getValueCache().remove(pk); 865 }); 866 } 867 } catch (SQLException se) { 868 throw new PersistenceDatabaseException(se); 869 } 870 871 pks.forEach((pk) -> { 872 session.removed(pk, true); 873 }); 874 } 875 } 876 877 @Override 878 public boolean validPK(PaymentProcessorActionPK pk) 879 throws PersistenceDatabaseException { 880 boolean valid = false; 881 PreparedStatement _ps = session.prepareStatement(SQL_VALID); 882 ResultSet _rs = null; 883 884 try { 885 _ps.setLong(1, pk.getEntityId()); 886 887 _rs = _ps.executeQuery(); 888 if(_rs.next()) { 889 long _count = _rs.getLong(1); 890 if(_rs.wasNull()) 891 _count = 0; 892 893 if(_count == 1) 894 valid = true; 895 } 896 } catch (SQLException se) { 897 throw new PersistenceDatabaseException(se); 898 } finally { 899 if(_rs != null) { 900 try { 901 _rs.close(); 902 } catch (SQLException se) { 903 // do nothing 904 } 905 } 906 } 907 908 return valid; 909 } 910 911}