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