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 * CurrencyFactory.java 021 */ 022 023package com.echothree.model.data.accounting.server.factory; 024 025import com.echothree.model.data.accounting.common.pk.SymbolPositionPK; 026 027import com.echothree.model.data.accounting.server.entity.SymbolPosition; 028 029import com.echothree.model.data.accounting.common.CurrencyConstants; 030import com.echothree.model.data.accounting.common.pk.CurrencyPK; 031import com.echothree.model.data.accounting.server.value.CurrencyValue; 032import com.echothree.model.data.accounting.server.entity.Currency; 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.jooq.ResultQuery; 057import org.slf4j.Logger; 058import org.slf4j.LoggerFactory; 059 060@ApplicationScoped 061public class CurrencyFactory 062 implements BaseFactory<CurrencyPK, Currency> { 063 064 @Inject 065 Session session; 066 067 //private static final Logger log = LoggerFactory.getLogger(CurrencyFactory.class); 068 069 final private static String SQL_SELECT_READ_ONLY = "SELECT cur_currencyid, cur_currencyisoname, cur_symbol, cur_sympos_symbolpositionid, cur_symbolonliststart, cur_symbolonlistmember, cur_symbolonsubtotal, cur_symbolontotal, cur_groupingseparator, cur_groupingsize, cur_fractionseparator, cur_defaultfractiondigits, cur_priceunitfractiondigits, cur_pricelinefractiondigits, cur_costunitfractiondigits, cur_costlinefractiondigits, cur_minussign, cur_isdefault, cur_sortorder FROM currencies WHERE cur_currencyid = ?"; 070 final private static String SQL_SELECT_READ_WRITE = "SELECT cur_currencyid, cur_currencyisoname, cur_symbol, cur_sympos_symbolpositionid, cur_symbolonliststart, cur_symbolonlistmember, cur_symbolonsubtotal, cur_symbolontotal, cur_groupingseparator, cur_groupingsize, cur_fractionseparator, cur_defaultfractiondigits, cur_priceunitfractiondigits, cur_pricelinefractiondigits, cur_costunitfractiondigits, cur_costlinefractiondigits, cur_minussign, cur_isdefault, cur_sortorder FROM currencies WHERE cur_currencyid = ? FOR UPDATE"; 071 final private static String SQL_INSERT = "INSERT INTO currencies (cur_currencyid, cur_currencyisoname, cur_symbol, cur_sympos_symbolpositionid, cur_symbolonliststart, cur_symbolonlistmember, cur_symbolonsubtotal, cur_symbolontotal, cur_groupingseparator, cur_groupingsize, cur_fractionseparator, cur_defaultfractiondigits, cur_priceunitfractiondigits, cur_pricelinefractiondigits, cur_costunitfractiondigits, cur_costlinefractiondigits, cur_minussign, cur_isdefault, cur_sortorder) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; 072 final private static String SQL_UPDATE = "UPDATE currencies SET cur_currencyisoname = ?, cur_symbol = ?, cur_sympos_symbolpositionid = ?, cur_symbolonliststart = ?, cur_symbolonlistmember = ?, cur_symbolonsubtotal = ?, cur_symbolontotal = ?, cur_groupingseparator = ?, cur_groupingsize = ?, cur_fractionseparator = ?, cur_defaultfractiondigits = ?, cur_priceunitfractiondigits = ?, cur_pricelinefractiondigits = ?, cur_costunitfractiondigits = ?, cur_costlinefractiondigits = ?, cur_minussign = ?, cur_isdefault = ?, cur_sortorder = ? WHERE cur_currencyid = ?"; 073 final private static String SQL_DELETE = "DELETE FROM currencies WHERE cur_currencyid = ?"; 074 final private static String SQL_VALID = "SELECT COUNT(*) FROM currencies WHERE cur_currencyid = ?"; 075 076 final private static String PK_COLUMN = "cur_currencyid"; 077 final private static String ALL_COLUMNS = "cur_currencyid, cur_currencyisoname, cur_symbol, cur_sympos_symbolpositionid, cur_symbolonliststart, cur_symbolonlistmember, cur_symbolonsubtotal, cur_symbolontotal, cur_groupingseparator, cur_groupingsize, cur_fractionseparator, cur_defaultfractiondigits, cur_priceunitfractiondigits, cur_pricelinefractiondigits, cur_costunitfractiondigits, cur_costlinefractiondigits, cur_minussign, cur_isdefault, cur_sortorder"; 078 final public static String TABLE_NAME = "currencies"; 079 080 final public static String CUR_CURRENCYID = "cur_currencyid"; 081 final public static String CUR_CURRENCYISONAME = "cur_currencyisoname"; 082 final public static String CUR_SYMBOL = "cur_symbol"; 083 final public static String CUR_SYMPOS_SYMBOLPOSITIONID = "cur_sympos_symbolpositionid"; 084 final public static String CUR_SYMBOLONLISTSTART = "cur_symbolonliststart"; 085 final public static String CUR_SYMBOLONLISTMEMBER = "cur_symbolonlistmember"; 086 final public static String CUR_SYMBOLONSUBTOTAL = "cur_symbolonsubtotal"; 087 final public static String CUR_SYMBOLONTOTAL = "cur_symbolontotal"; 088 final public static String CUR_GROUPINGSEPARATOR = "cur_groupingseparator"; 089 final public static String CUR_GROUPINGSIZE = "cur_groupingsize"; 090 final public static String CUR_FRACTIONSEPARATOR = "cur_fractionseparator"; 091 final public static String CUR_DEFAULTFRACTIONDIGITS = "cur_defaultfractiondigits"; 092 final public static String CUR_PRICEUNITFRACTIONDIGITS = "cur_priceunitfractiondigits"; 093 final public static String CUR_PRICELINEFRACTIONDIGITS = "cur_pricelinefractiondigits"; 094 final public static String CUR_COSTUNITFRACTIONDIGITS = "cur_costunitfractiondigits"; 095 final public static String CUR_COSTLINEFRACTIONDIGITS = "cur_costlinefractiondigits"; 096 final public static String CUR_MINUSSIGN = "cur_minussign"; 097 final public static String CUR_ISDEFAULT = "cur_isdefault"; 098 final public static String CUR_SORTORDER = "cur_sortorder"; 099 100 final private static EntityIdGenerator entityIdGenerator = new EntityIdGenerator(CurrencyConstants.COMPONENT_VENDOR_NAME, CurrencyConstants.ENTITY_TYPE_NAME); 101 102 /** Creates a new instance of CurrencyFactory */ 103 protected CurrencyFactory() { 104 super(); 105 } 106 107 public static CurrencyFactory getInstance() { 108 return CDI.current().select(CurrencyFactory.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 CurrencyConstants.COMPONENT_VENDOR_NAME; 129 } 130 131 @Override 132 public String getEntityTypeName() { 133 return CurrencyConstants.ENTITY_TYPE_NAME; 134 } 135 136 public PreparedStatement prepareStatement(String query) { 137 return session.prepareStatement(CurrencyFactory.class, query); 138 } 139 140 public CurrencyPK getNextPK() { 141 return new CurrencyPK(entityIdGenerator.getNextEntityId()); 142 } 143 144 public Set<CurrencyPK> getPKsFromResultSetAsSet(ResultSet rs) 145 throws PersistenceDatabaseException { 146 Set<CurrencyPK> _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<CurrencyPK> getPKsFromResultSetAsList(ResultSet rs) 160 throws PersistenceDatabaseException { 161 java.util.List<CurrencyPK> _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 CurrencyPK getPKFromResultSet(ResultSet rs) 175 throws PersistenceDatabaseException { 176 CurrencyPK _result; 177 178 try { 179 long cur_currencyid = rs.getLong(CUR_CURRENCYID); 180 Long _entityId = rs.wasNull() ? null : cur_currencyid; 181 182 _result = new CurrencyPK(_entityId); 183 } catch (SQLException se) { 184 throw new PersistenceDatabaseException(se); 185 } 186 187 return _result; 188 } 189 190 public java.util.List<CurrencyValue> getValuesFromPKs(Collection<CurrencyPK> pks) 191 throws PersistenceDatabaseException { 192 java.util.List<CurrencyValue> _values = new ArrayList<>(pks.size()); 193 194 for(CurrencyPK _pk: pks) { 195 _values.add(getValueFromPK(_pk)); 196 } 197 198 return _values; 199 } 200 201 public CurrencyValue getValueFromPK(CurrencyPK pk) 202 throws PersistenceDatabaseException { 203 CurrencyValue _value; 204 205 // See if we already have the entity in the session cache 206 Currency _entity = (Currency)session.getEntity(pk); 207 if(_entity == null) 208 _value = getEntityFromPK(EntityPermission.READ_ONLY, pk).getCurrencyValue(); 209 else 210 _value = _entity.getCurrencyValue(); 211 212 return _value; 213 } 214 215 public java.util.List<CurrencyValue> getValuesFromResultSet(ResultSet rs) 216 throws PersistenceDatabaseException { 217 java.util.List<CurrencyValue> _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 CurrencyValue getValueFromResultSet(ResultSet rs) 231 throws PersistenceDatabaseException { 232 CurrencyValue _value; 233 234 try { 235 Long cur_currencyid = rs.getLong(CUR_CURRENCYID); 236 CurrencyPK _pk = new CurrencyPK(cur_currencyid); 237 238 // See if we already have the entity in the session cache 239 Currency _entity = (Currency)session.getEntity(_pk); 240 241 if(_entity == null) { 242 String cur_currencyisoname = rs.getString(CUR_CURRENCYISONAME); 243 if(rs.wasNull()) 244 cur_currencyisoname = null; 245 246 String cur_symbol = rs.getString(CUR_SYMBOL); 247 if(rs.wasNull()) 248 cur_symbol = null; 249 250 Long cur_sympos_symbolpositionid = rs.getLong(CUR_SYMPOS_SYMBOLPOSITIONID); 251 if(rs.wasNull()) 252 cur_sympos_symbolpositionid = null; 253 254 Boolean cur_symbolonliststart = rs.getInt(CUR_SYMBOLONLISTSTART) == 1; 255 if(rs.wasNull()) 256 cur_symbolonliststart = null; 257 258 Boolean cur_symbolonlistmember = rs.getInt(CUR_SYMBOLONLISTMEMBER) == 1; 259 if(rs.wasNull()) 260 cur_symbolonlistmember = null; 261 262 Boolean cur_symbolonsubtotal = rs.getInt(CUR_SYMBOLONSUBTOTAL) == 1; 263 if(rs.wasNull()) 264 cur_symbolonsubtotal = null; 265 266 Boolean cur_symbolontotal = rs.getInt(CUR_SYMBOLONTOTAL) == 1; 267 if(rs.wasNull()) 268 cur_symbolontotal = null; 269 270 String cur_groupingseparator = rs.getString(CUR_GROUPINGSEPARATOR); 271 if(rs.wasNull()) 272 cur_groupingseparator = null; 273 274 Integer cur_groupingsize = rs.getInt(CUR_GROUPINGSIZE); 275 if(rs.wasNull()) 276 cur_groupingsize = null; 277 278 String cur_fractionseparator = rs.getString(CUR_FRACTIONSEPARATOR); 279 if(rs.wasNull()) 280 cur_fractionseparator = null; 281 282 Integer cur_defaultfractiondigits = rs.getInt(CUR_DEFAULTFRACTIONDIGITS); 283 if(rs.wasNull()) 284 cur_defaultfractiondigits = null; 285 286 Integer cur_priceunitfractiondigits = rs.getInt(CUR_PRICEUNITFRACTIONDIGITS); 287 if(rs.wasNull()) 288 cur_priceunitfractiondigits = null; 289 290 Integer cur_pricelinefractiondigits = rs.getInt(CUR_PRICELINEFRACTIONDIGITS); 291 if(rs.wasNull()) 292 cur_pricelinefractiondigits = null; 293 294 Integer cur_costunitfractiondigits = rs.getInt(CUR_COSTUNITFRACTIONDIGITS); 295 if(rs.wasNull()) 296 cur_costunitfractiondigits = null; 297 298 Integer cur_costlinefractiondigits = rs.getInt(CUR_COSTLINEFRACTIONDIGITS); 299 if(rs.wasNull()) 300 cur_costlinefractiondigits = null; 301 302 String cur_minussign = rs.getString(CUR_MINUSSIGN); 303 if(rs.wasNull()) 304 cur_minussign = null; 305 306 Boolean cur_isdefault = rs.getInt(CUR_ISDEFAULT) == 1; 307 if(rs.wasNull()) 308 cur_isdefault = null; 309 310 Integer cur_sortorder = rs.getInt(CUR_SORTORDER); 311 if(rs.wasNull()) 312 cur_sortorder = null; 313 314 _value = new CurrencyValue(_pk, cur_currencyisoname, cur_symbol, new SymbolPositionPK(cur_sympos_symbolpositionid), cur_symbolonliststart, cur_symbolonlistmember, cur_symbolonsubtotal, cur_symbolontotal, cur_groupingseparator, cur_groupingsize, cur_fractionseparator, cur_defaultfractiondigits, cur_priceunitfractiondigits, cur_pricelinefractiondigits, cur_costunitfractiondigits, cur_costlinefractiondigits, cur_minussign, cur_isdefault, cur_sortorder); 315 } else 316 _value = _entity.getCurrencyValue(); 317 } catch (SQLException se) { 318 throw new PersistenceDatabaseException(se); 319 } 320 321 return _value; 322 } 323 324 public java.util.List<Currency> getEntitiesFromPKs(EntityPermission entityPermission, Collection<CurrencyPK> pks) 325 throws PersistenceDatabaseException { 326 java.util.List<Currency> _entities = new ArrayList<>(pks.size()); 327 328 for(CurrencyPK _pk: pks) { 329 _entities.add(getEntityFromPK(entityPermission, _pk)); 330 } 331 332 return _entities; 333 } 334 335 public Currency getEntityFromValue(EntityPermission entityPermission, CurrencyValue value) { 336 return getEntityFromPK(entityPermission, value.getPrimaryKey()); 337 } 338 339 public Currency getEntityFromCache(CurrencyPK pk) { 340 CurrencyValue _value = (CurrencyValue)session.getValueCache().get(pk); 341 342 return _value == null ? null : new Currency(_value, EntityPermission.READ_ONLY); 343 } 344 345 public Currency getEntityFromPK(EntityPermission entityPermission, CurrencyPK pk) 346 throws PersistenceDatabaseException { 347 Currency _entity; 348 349 // See if we already have the entity in the session cache 350 _entity = (Currency)session.getEntity(pk); 351 if(_entity != null) { 352 // If the requested permission is READ_WRITE, and the cached permission is 353 // READ_ONLY, then pretend that the cached object wasn't found, and create 354 // a new entity that is READ_WRITE. 355 if(entityPermission.equals(EntityPermission.READ_WRITE)) { 356 if(_entity.getEntityPermission().equals(EntityPermission.READ_ONLY)) 357 _entity = null; 358 } 359 } 360 361 if(_entity == null && entityPermission.equals(EntityPermission.READ_ONLY)) { 362 _entity = getEntityFromCache(pk); 363 } 364 365 if(_entity == null) { 366 PreparedStatement _ps = session.prepareStatement(entityPermission.equals(EntityPermission.READ_ONLY)? SQL_SELECT_READ_ONLY: SQL_SELECT_READ_WRITE); 367 long _entityId = pk.getEntityId(); 368 ResultSet _rs = null; 369 370 try { 371 _ps.setLong(1, _entityId); 372 _rs = _ps.executeQuery(); 373 if(_rs.next()) { 374 _entity = getEntityFromResultSet(entityPermission, _rs); 375 } 376 } catch (SQLException se) { 377 throw new PersistenceDatabaseException(se); 378 } finally { 379 if(_rs != null) { 380 try { 381 _rs.close(); 382 } catch (SQLException se) { 383 // do nothing 384 } 385 } 386 } 387 } 388 389 return _entity; 390 } 391 392 public Set<CurrencyPK> getPKsFromQueryAsSet(PreparedStatement ps, final Object... params) 393 throws PersistenceDatabaseException { 394 Set<CurrencyPK> _pks; 395 ResultSet _rs = null; 396 397 try { 398 if(params.length != 0) { 399 Session.setQueryParams(ps, params); 400 } 401 402 _rs = ps.executeQuery(); 403 _pks = getPKsFromResultSetAsSet(_rs); 404 _rs.close(); 405 } catch (SQLException se) { 406 throw new PersistenceDatabaseException(se); 407 } finally { 408 if(_rs != null) { 409 try { 410 _rs.close(); 411 } catch (SQLException se) { 412 // do nothing 413 } 414 } 415 } 416 417 return _pks; 418 } 419 420 public java.util.List<CurrencyPK> getPKsFromQueryAsList(PreparedStatement ps, final Object... params) 421 throws PersistenceDatabaseException { 422 java.util.List<CurrencyPK> _pks; 423 ResultSet _rs = null; 424 425 try { 426 if(params.length != 0) { 427 Session.setQueryParams(ps, params); 428 } 429 430 _rs = ps.executeQuery(); 431 _pks = getPKsFromResultSetAsList(_rs); 432 _rs.close(); 433 } catch (SQLException se) { 434 throw new PersistenceDatabaseException(se); 435 } finally { 436 if(_rs != null) { 437 try { 438 _rs.close(); 439 } catch (SQLException se) { 440 // do nothing 441 } 442 } 443 } 444 445 return _pks; 446 } 447 448 public CurrencyPK getPKFromQuery(PreparedStatement ps, final Object... params) 449 throws PersistenceDatabaseException { 450 CurrencyPK _pk = null; 451 ResultSet _rs = null; 452 453 try { 454 if(params.length != 0) { 455 Session.setQueryParams(ps, params); 456 } 457 458 _rs = ps.executeQuery(); 459 if(_rs.next()) { 460 _pk = getPKFromResultSet(_rs); 461 } 462 _rs.close(); 463 } catch (SQLException se) { 464 throw new PersistenceDatabaseException(se); 465 } finally { 466 if(_rs != null) { 467 try { 468 _rs.close(); 469 } catch (SQLException se) { 470 // do nothing 471 } 472 } 473 } 474 475 return _pk; 476 } 477 478 public java.util.List<Currency> getEntitiesFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap, final Object... params) 479 throws PersistenceDatabaseException { 480 PreparedStatement ps = session.prepareStatement(CurrencyFactory.class, queryMap.get(entityPermission)); 481 482 return getEntitiesFromQuery(entityPermission, ps, params); 483 } 484 485 public java.util.List<Currency> getEntitiesFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap) 486 throws PersistenceDatabaseException { 487 PreparedStatement ps = session.prepareStatement(CurrencyFactory.class, queryMap.get(entityPermission)); 488 489 return getEntitiesFromQuery(entityPermission, ps); 490 } 491 492 public java.util.List<Currency> getEntitiesFromQuery(EntityPermission entityPermission, ResultQuery<?> query) 493 throws PersistenceDatabaseException { 494 PreparedStatement ps = session.prepareStatement(CurrencyFactory.class, query.getSQL()); 495 496 return getEntitiesFromQuery(entityPermission, ps, query.getBindValues().toArray()); 497 } 498 499 public java.util.List<Currency> getEntitiesFromQuery(EntityPermission entityPermission, PreparedStatement ps, final Object... params) 500 throws PersistenceDatabaseException { 501 java.util.List<Currency> _entities; 502 ResultSet _rs = null; 503 504 try { 505 if(params.length != 0) { 506 Session.setQueryParams(ps, params); 507 } 508 509 _rs = ps.executeQuery(); 510 _entities = getEntitiesFromResultSet(entityPermission, _rs); 511 _rs.close(); 512 } catch (SQLException se) { 513 throw new PersistenceDatabaseException(se); 514 } finally { 515 if(_rs != null) { 516 try { 517 _rs.close(); 518 } catch (SQLException se) { 519 // do nothing 520 } 521 } 522 } 523 524 return _entities; 525 } 526 527 public Currency getEntityFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap, final Object... params) 528 throws PersistenceDatabaseException { 529 PreparedStatement ps = session.prepareStatement(CurrencyFactory.class, queryMap.get(entityPermission)); 530 531 return getEntityFromQuery(entityPermission, ps, params); 532 } 533 534 public Currency getEntityFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap) 535 throws PersistenceDatabaseException { 536 PreparedStatement ps = session.prepareStatement(CurrencyFactory.class, queryMap.get(entityPermission)); 537 538 return getEntityFromQuery(entityPermission, ps); 539 } 540 541 public Currency getEntityFromQuery(EntityPermission entityPermission, ResultQuery<?> query) 542 throws PersistenceDatabaseException { 543 PreparedStatement ps = session.prepareStatement(CurrencyFactory.class, query.getSQL()); 544 545 return getEntityFromQuery(entityPermission, ps, query.getBindValues().toArray()); 546 } 547 548 public Currency getEntityFromQuery(EntityPermission entityPermission, PreparedStatement ps, final Object... params) 549 throws PersistenceDatabaseException { 550 Currency _entity = null; 551 ResultSet _rs = null; 552 553 try { 554 if(params.length != 0) { 555 Session.setQueryParams(ps, params); 556 } 557 558 _rs = ps.executeQuery(); 559 if(_rs.next()) { 560 _entity = getEntityFromResultSet(entityPermission, _rs); 561 } 562 _rs.close(); 563 } catch (SQLException se) { 564 throw new PersistenceDatabaseException(se); 565 } finally { 566 if(_rs != null) { 567 try { 568 _rs.close(); 569 } catch (SQLException se) { 570 // do nothing 571 } 572 } 573 } 574 575 return _entity; 576 } 577 578 public java.util.List<Currency> getEntitiesFromResultSet(EntityPermission entityPermission, ResultSet rs) 579 throws PersistenceDatabaseException { 580 java.util.List<Currency> _result = new ArrayList<>(); 581 582 try { 583 while(rs.next()) { 584 _result.add(getEntityFromResultSet(entityPermission, rs)); 585 } 586 } catch (SQLException se) { 587 throw new PersistenceDatabaseException(se); 588 } 589 590 return _result; 591 } 592 593 public Currency getEntityFromResultSet(EntityPermission entityPermission, ResultSet rs) 594 throws PersistenceDatabaseException { 595 Currency _entity; 596 597 try { 598 Long cur_currencyid = rs.getLong(CUR_CURRENCYID); 599 CurrencyPK _pk = new CurrencyPK(cur_currencyid); 600 601 // See if we already have the entity in the session cache 602 _entity = (Currency)session.getEntity(_pk); 603 if(_entity != null) { 604 // If the requested permission is READ_WRITE, and the cached permission is 605 // READ_ONLY, then pretend that the cached object wasn't found, and create 606 // a new entity that is READ_WRITE. 607 if(entityPermission.equals(EntityPermission.READ_WRITE)) { 608 if(_entity.getEntityPermission().equals(EntityPermission.READ_ONLY)) 609 _entity = null; 610 } 611 } 612 boolean foundInSessionCache = _entity != null; 613 614 if(_entity == null && entityPermission.equals(EntityPermission.READ_ONLY)) { 615 _entity = getEntityFromCache(_pk); 616 } 617 618 if(_entity == null) { 619 String cur_currencyisoname = rs.getString(CUR_CURRENCYISONAME); 620 if(rs.wasNull()) 621 cur_currencyisoname = null; 622 623 String cur_symbol = rs.getString(CUR_SYMBOL); 624 if(rs.wasNull()) 625 cur_symbol = null; 626 627 Long cur_sympos_symbolpositionid = rs.getLong(CUR_SYMPOS_SYMBOLPOSITIONID); 628 if(rs.wasNull()) 629 cur_sympos_symbolpositionid = null; 630 631 Boolean cur_symbolonliststart = rs.getInt(CUR_SYMBOLONLISTSTART) == 1; 632 if(rs.wasNull()) 633 cur_symbolonliststart = null; 634 635 Boolean cur_symbolonlistmember = rs.getInt(CUR_SYMBOLONLISTMEMBER) == 1; 636 if(rs.wasNull()) 637 cur_symbolonlistmember = null; 638 639 Boolean cur_symbolonsubtotal = rs.getInt(CUR_SYMBOLONSUBTOTAL) == 1; 640 if(rs.wasNull()) 641 cur_symbolonsubtotal = null; 642 643 Boolean cur_symbolontotal = rs.getInt(CUR_SYMBOLONTOTAL) == 1; 644 if(rs.wasNull()) 645 cur_symbolontotal = null; 646 647 String cur_groupingseparator = rs.getString(CUR_GROUPINGSEPARATOR); 648 if(rs.wasNull()) 649 cur_groupingseparator = null; 650 651 Integer cur_groupingsize = rs.getInt(CUR_GROUPINGSIZE); 652 if(rs.wasNull()) 653 cur_groupingsize = null; 654 655 String cur_fractionseparator = rs.getString(CUR_FRACTIONSEPARATOR); 656 if(rs.wasNull()) 657 cur_fractionseparator = null; 658 659 Integer cur_defaultfractiondigits = rs.getInt(CUR_DEFAULTFRACTIONDIGITS); 660 if(rs.wasNull()) 661 cur_defaultfractiondigits = null; 662 663 Integer cur_priceunitfractiondigits = rs.getInt(CUR_PRICEUNITFRACTIONDIGITS); 664 if(rs.wasNull()) 665 cur_priceunitfractiondigits = null; 666 667 Integer cur_pricelinefractiondigits = rs.getInt(CUR_PRICELINEFRACTIONDIGITS); 668 if(rs.wasNull()) 669 cur_pricelinefractiondigits = null; 670 671 Integer cur_costunitfractiondigits = rs.getInt(CUR_COSTUNITFRACTIONDIGITS); 672 if(rs.wasNull()) 673 cur_costunitfractiondigits = null; 674 675 Integer cur_costlinefractiondigits = rs.getInt(CUR_COSTLINEFRACTIONDIGITS); 676 if(rs.wasNull()) 677 cur_costlinefractiondigits = null; 678 679 String cur_minussign = rs.getString(CUR_MINUSSIGN); 680 if(rs.wasNull()) 681 cur_minussign = null; 682 683 Boolean cur_isdefault = rs.getInt(CUR_ISDEFAULT) == 1; 684 if(rs.wasNull()) 685 cur_isdefault = null; 686 687 Integer cur_sortorder = rs.getInt(CUR_SORTORDER); 688 if(rs.wasNull()) 689 cur_sortorder = null; 690 691 CurrencyValue _value = new CurrencyValue(_pk, cur_currencyisoname, cur_symbol, cur_sympos_symbolpositionid == null? null: new SymbolPositionPK(cur_sympos_symbolpositionid), cur_symbolonliststart, cur_symbolonlistmember, cur_symbolonsubtotal, cur_symbolontotal, cur_groupingseparator, cur_groupingsize, cur_fractionseparator, cur_defaultfractiondigits, cur_priceunitfractiondigits, cur_pricelinefractiondigits, cur_costunitfractiondigits, cur_costlinefractiondigits, cur_minussign, cur_isdefault, cur_sortorder); 692 _entity = new Currency(_value, entityPermission); 693 } 694 695 if(!foundInSessionCache) { 696 if(entityPermission.equals(EntityPermission.READ_ONLY)) { 697 session.putReadOnlyEntity(_pk, _entity); 698 session.getValueCache().put(_entity.getCurrencyValue()); 699 } else { 700 session.putReadWriteEntity(_pk, _entity); 701 } 702 } 703 } catch (SQLException se) { 704 throw new PersistenceDatabaseException(se); 705 } 706 707 return _entity; 708 } 709 710 public Currency create(String currencyIsoName, String symbol, SymbolPosition symbolPosition, Boolean symbolOnListStart, Boolean symbolOnListMember, Boolean symbolOnSubtotal, Boolean symbolOnTotal, String groupingSeparator, Integer groupingSize, String fractionSeparator, Integer defaultFractionDigits, Integer priceUnitFractionDigits, Integer priceLineFractionDigits, Integer costUnitFractionDigits, Integer costLineFractionDigits, String minusSign, Boolean isDefault, Integer sortOrder) 711 throws PersistenceDatabaseException, PersistenceNotNullException { 712 return create(currencyIsoName, symbol, symbolPosition == null ? null : symbolPosition.getPrimaryKey(), symbolOnListStart, symbolOnListMember, symbolOnSubtotal, symbolOnTotal, groupingSeparator, groupingSize, fractionSeparator, defaultFractionDigits, priceUnitFractionDigits, priceLineFractionDigits, costUnitFractionDigits, costLineFractionDigits, minusSign, isDefault, sortOrder); 713 } 714 715 private void bindForCreate(PreparedStatement _ps, CurrencyValue _value) 716 throws SQLException { 717 _ps.setLong(1, _value.getEntityId()); 718 719 String cur_currencyisoname = _value.getCurrencyIsoName(); 720 if(cur_currencyisoname == null) 721 _ps.setNull(2, Types.VARCHAR); 722 else 723 _ps.setString(2, cur_currencyisoname); 724 725 String cur_symbol = _value.getSymbol(); 726 if(cur_symbol == null) 727 _ps.setNull(3, Types.VARCHAR); 728 else 729 _ps.setString(3, cur_symbol); 730 731 SymbolPositionPK cur_sympos_symbolpositionid = _value.getSymbolPositionPK(); 732 if(cur_sympos_symbolpositionid == null) 733 _ps.setNull(4, Types.BIGINT); 734 else 735 _ps.setLong(4, cur_sympos_symbolpositionid.getEntityId()); 736 737 Boolean cur_symbolonliststart = _value.getSymbolOnListStart(); 738 if(cur_symbolonliststart == null) 739 _ps.setNull(5, Types.BIT); 740 else 741 _ps.setInt(5, cur_symbolonliststart? 1: 0); 742 743 Boolean cur_symbolonlistmember = _value.getSymbolOnListMember(); 744 if(cur_symbolonlistmember == null) 745 _ps.setNull(6, Types.BIT); 746 else 747 _ps.setInt(6, cur_symbolonlistmember? 1: 0); 748 749 Boolean cur_symbolonsubtotal = _value.getSymbolOnSubtotal(); 750 if(cur_symbolonsubtotal == null) 751 _ps.setNull(7, Types.BIT); 752 else 753 _ps.setInt(7, cur_symbolonsubtotal? 1: 0); 754 755 Boolean cur_symbolontotal = _value.getSymbolOnTotal(); 756 if(cur_symbolontotal == null) 757 _ps.setNull(8, Types.BIT); 758 else 759 _ps.setInt(8, cur_symbolontotal? 1: 0); 760 761 String cur_groupingseparator = _value.getGroupingSeparator(); 762 if(cur_groupingseparator == null) 763 _ps.setNull(9, Types.VARCHAR); 764 else 765 _ps.setString(9, cur_groupingseparator); 766 767 Integer cur_groupingsize = _value.getGroupingSize(); 768 if(cur_groupingsize == null) 769 _ps.setNull(10, Types.INTEGER); 770 else 771 _ps.setInt(10, cur_groupingsize); 772 773 String cur_fractionseparator = _value.getFractionSeparator(); 774 if(cur_fractionseparator == null) 775 _ps.setNull(11, Types.VARCHAR); 776 else 777 _ps.setString(11, cur_fractionseparator); 778 779 Integer cur_defaultfractiondigits = _value.getDefaultFractionDigits(); 780 if(cur_defaultfractiondigits == null) 781 _ps.setNull(12, Types.INTEGER); 782 else 783 _ps.setInt(12, cur_defaultfractiondigits); 784 785 Integer cur_priceunitfractiondigits = _value.getPriceUnitFractionDigits(); 786 if(cur_priceunitfractiondigits == null) 787 _ps.setNull(13, Types.INTEGER); 788 else 789 _ps.setInt(13, cur_priceunitfractiondigits); 790 791 Integer cur_pricelinefractiondigits = _value.getPriceLineFractionDigits(); 792 if(cur_pricelinefractiondigits == null) 793 _ps.setNull(14, Types.INTEGER); 794 else 795 _ps.setInt(14, cur_pricelinefractiondigits); 796 797 Integer cur_costunitfractiondigits = _value.getCostUnitFractionDigits(); 798 if(cur_costunitfractiondigits == null) 799 _ps.setNull(15, Types.INTEGER); 800 else 801 _ps.setInt(15, cur_costunitfractiondigits); 802 803 Integer cur_costlinefractiondigits = _value.getCostLineFractionDigits(); 804 if(cur_costlinefractiondigits == null) 805 _ps.setNull(16, Types.INTEGER); 806 else 807 _ps.setInt(16, cur_costlinefractiondigits); 808 809 String cur_minussign = _value.getMinusSign(); 810 if(cur_minussign == null) 811 _ps.setNull(17, Types.VARCHAR); 812 else 813 _ps.setString(17, cur_minussign); 814 815 Boolean cur_isdefault = _value.getIsDefault(); 816 if(cur_isdefault == null) 817 _ps.setNull(18, Types.BIT); 818 else 819 _ps.setInt(18, cur_isdefault? 1: 0); 820 821 Integer cur_sortorder = _value.getSortOrder(); 822 if(cur_sortorder == null) 823 _ps.setNull(19, Types.INTEGER); 824 else 825 _ps.setInt(19, cur_sortorder); 826 827 } 828 829 public Currency create(String currencyIsoName, String symbol, SymbolPositionPK symbolPositionPK, Boolean symbolOnListStart, Boolean symbolOnListMember, Boolean symbolOnSubtotal, Boolean symbolOnTotal, String groupingSeparator, Integer groupingSize, String fractionSeparator, Integer defaultFractionDigits, Integer priceUnitFractionDigits, Integer priceLineFractionDigits, Integer costUnitFractionDigits, Integer costLineFractionDigits, String minusSign, Boolean isDefault, Integer sortOrder) 830 throws PersistenceDatabaseException, PersistenceNotNullException { 831 CurrencyPK _pk = getNextPK(); 832 CurrencyValue _value = new CurrencyValue(_pk, currencyIsoName, symbol, symbolPositionPK, symbolOnListStart, symbolOnListMember, symbolOnSubtotal, symbolOnTotal, groupingSeparator, groupingSize, fractionSeparator, defaultFractionDigits, priceUnitFractionDigits, priceLineFractionDigits, costUnitFractionDigits, costLineFractionDigits, minusSign, isDefault, sortOrder); 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 Currency _entity = new Currency(_value, EntityPermission.READ_ONLY); 855 session.putReadOnlyEntity(_pk, _entity); 856 857 return _entity; 858 } 859 860 public void create(Collection<CurrencyValue> _values) 861 throws PersistenceDatabaseException, PersistenceNotNullException { 862 int _size = _values.size(); 863 864 if(_size > 0) { 865 PreparedStatement _ps = session.prepareStatement(SQL_INSERT); 866 List<CurrencyValue> _cacheValues = new ArrayList<>(_size); 867 868 try { 869 for(CurrencyValue _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 Currency _cacheEntity = new Currency(_cacheValue, EntityPermission.READ_ONLY); 897 898 session.putReadOnlyEntity(_cacheValue.getPrimaryKey(), _cacheEntity); 899 }); 900 } 901 } 902 903 private boolean bindForStore(PreparedStatement _ps, CurrencyValue _value) 904 throws SQLException { 905 boolean _hasBeenModified = _value.hasBeenModified(); 906 907 if(_hasBeenModified) { 908 String cur_currencyisoname = _value.getCurrencyIsoName(); 909 if(cur_currencyisoname == null) 910 _ps.setNull(1, Types.VARCHAR); 911 else 912 _ps.setString(1, cur_currencyisoname); 913 914 String cur_symbol = _value.getSymbol(); 915 if(cur_symbol == null) 916 _ps.setNull(2, Types.VARCHAR); 917 else 918 _ps.setString(2, cur_symbol); 919 920 SymbolPositionPK cur_sympos_symbolpositionid = _value.getSymbolPositionPK(); 921 if(cur_sympos_symbolpositionid == null) 922 _ps.setNull(3, Types.BIGINT); 923 else 924 _ps.setLong(3, cur_sympos_symbolpositionid.getEntityId()); 925 926 Boolean cur_symbolonliststart = _value.getSymbolOnListStart(); 927 if(cur_symbolonliststart == null) 928 _ps.setNull(4, Types.BIT); 929 else 930 _ps.setInt(4, cur_symbolonliststart? 1: 0); 931 932 Boolean cur_symbolonlistmember = _value.getSymbolOnListMember(); 933 if(cur_symbolonlistmember == null) 934 _ps.setNull(5, Types.BIT); 935 else 936 _ps.setInt(5, cur_symbolonlistmember? 1: 0); 937 938 Boolean cur_symbolonsubtotal = _value.getSymbolOnSubtotal(); 939 if(cur_symbolonsubtotal == null) 940 _ps.setNull(6, Types.BIT); 941 else 942 _ps.setInt(6, cur_symbolonsubtotal? 1: 0); 943 944 Boolean cur_symbolontotal = _value.getSymbolOnTotal(); 945 if(cur_symbolontotal == null) 946 _ps.setNull(7, Types.BIT); 947 else 948 _ps.setInt(7, cur_symbolontotal? 1: 0); 949 950 String cur_groupingseparator = _value.getGroupingSeparator(); 951 if(cur_groupingseparator == null) 952 _ps.setNull(8, Types.VARCHAR); 953 else 954 _ps.setString(8, cur_groupingseparator); 955 956 Integer cur_groupingsize = _value.getGroupingSize(); 957 if(cur_groupingsize == null) 958 _ps.setNull(9, Types.INTEGER); 959 else 960 _ps.setInt(9, cur_groupingsize); 961 962 String cur_fractionseparator = _value.getFractionSeparator(); 963 if(cur_fractionseparator == null) 964 _ps.setNull(10, Types.VARCHAR); 965 else 966 _ps.setString(10, cur_fractionseparator); 967 968 Integer cur_defaultfractiondigits = _value.getDefaultFractionDigits(); 969 if(cur_defaultfractiondigits == null) 970 _ps.setNull(11, Types.INTEGER); 971 else 972 _ps.setInt(11, cur_defaultfractiondigits); 973 974 Integer cur_priceunitfractiondigits = _value.getPriceUnitFractionDigits(); 975 if(cur_priceunitfractiondigits == null) 976 _ps.setNull(12, Types.INTEGER); 977 else 978 _ps.setInt(12, cur_priceunitfractiondigits); 979 980 Integer cur_pricelinefractiondigits = _value.getPriceLineFractionDigits(); 981 if(cur_pricelinefractiondigits == null) 982 _ps.setNull(13, Types.INTEGER); 983 else 984 _ps.setInt(13, cur_pricelinefractiondigits); 985 986 Integer cur_costunitfractiondigits = _value.getCostUnitFractionDigits(); 987 if(cur_costunitfractiondigits == null) 988 _ps.setNull(14, Types.INTEGER); 989 else 990 _ps.setInt(14, cur_costunitfractiondigits); 991 992 Integer cur_costlinefractiondigits = _value.getCostLineFractionDigits(); 993 if(cur_costlinefractiondigits == null) 994 _ps.setNull(15, Types.INTEGER); 995 else 996 _ps.setInt(15, cur_costlinefractiondigits); 997 998 String cur_minussign = _value.getMinusSign(); 999 if(cur_minussign == null) 1000 _ps.setNull(16, Types.VARCHAR); 1001 else 1002 _ps.setString(16, cur_minussign); 1003 1004 Boolean cur_isdefault = _value.getIsDefault(); 1005 if(cur_isdefault == null) 1006 _ps.setNull(17, Types.BIT); 1007 else 1008 _ps.setInt(17, cur_isdefault? 1: 0); 1009 1010 Integer cur_sortorder = _value.getSortOrder(); 1011 if(cur_sortorder == null) 1012 _ps.setNull(18, Types.INTEGER); 1013 else 1014 _ps.setInt(18, cur_sortorder); 1015 1016 _ps.setLong(19, _value.getPrimaryKey().getEntityId()); 1017 1018 _value.clearHasBeenModified(); 1019 } 1020 1021 return _hasBeenModified; 1022 } 1023 1024 @Override 1025 public void store(Currency entity) 1026 throws PersistenceDatabaseException { 1027 PreparedStatement _ps = session.prepareStatement(SQL_UPDATE); 1028 1029 try { 1030 CurrencyValue _value = entity.getCurrencyValue(); 1031 1032 if(bindForStore(_ps, _value)) { 1033 if(PersistenceDebugFlags.CheckEntityUpdateRowCount) { 1034 int _count = _ps.executeUpdate(); 1035 1036 if(_count != 1) { 1037 throw new PersistenceDatabaseUpdateException("update failed, _count = " + _count); 1038 } 1039 } else { 1040 _ps.executeUpdate(); 1041 } 1042 1043 session.getValueCache().put(_value); 1044 } 1045 } catch (SQLException se) { 1046 throw new PersistenceDatabaseException(se); 1047 } 1048 } 1049 1050 @Override 1051 public void store(Collection<Currency> entities) 1052 throws PersistenceDatabaseException { 1053 if(entities.size() > 0) { 1054 PreparedStatement _ps = session.prepareStatement(SQL_UPDATE); 1055 int _modifiedEntities = 0; 1056 1057 try { 1058 for(Currency entity : entities) { 1059 if(bindForStore(_ps, entity.getCurrencyValue())) { 1060 _ps.addBatch(); 1061 _modifiedEntities++; 1062 } 1063 } 1064 1065 if(_modifiedEntities != 0) { 1066 if(PersistenceDebugFlags.CheckEntityUpdateRowCount) { 1067 int[] _counts = _ps.executeBatch(); 1068 1069 for(int _countOffset = 0 ; _countOffset < _modifiedEntities ; _countOffset++) { 1070 if(_counts[_countOffset] != 1 && _counts[_countOffset] != PreparedStatement.SUCCESS_NO_INFO) { 1071 throw new PersistenceDatabaseUpdateException("batch update failed, _counts[" + _countOffset + "] = " + _counts[_countOffset]); 1072 } 1073 } 1074 } else { 1075 _ps.executeBatch(); 1076 } 1077 1078 _ps.clearBatch(); 1079 1080 entities.forEach((entity) -> { 1081 session.getValueCache().put(entity.getCurrencyValue()); 1082 }); 1083 } 1084 } catch (SQLException se) { 1085 throw new PersistenceDatabaseException(se); 1086 } 1087 } 1088 } 1089 1090 @Override 1091 public void remove(Currency entity) 1092 throws PersistenceDatabaseException { 1093 remove(entity.getPrimaryKey()); 1094 } 1095 1096 @Override 1097 public void remove(CurrencyPK pk) 1098 throws PersistenceDatabaseException { 1099 PreparedStatement _ps = session.prepareStatement(SQL_DELETE); 1100 long _entityId = pk.getEntityId(); 1101 1102 try { 1103 _ps.setLong(1, _entityId); 1104 1105 if(PersistenceDebugFlags.CheckEntityDeleteRowCount) { 1106 int _count = _ps.executeUpdate(); 1107 1108 if(_count != 1) { 1109 throw new PersistenceDatabaseUpdateException("remove failed, _count = " + _count); 1110 } 1111 } else { 1112 _ps.executeUpdate(); 1113 } 1114 1115 session.getValueCache().remove(pk); 1116 } catch (SQLException se) { 1117 throw new PersistenceDatabaseException(se); 1118 } 1119 1120 session.removed(pk, false); 1121 } 1122 1123 @Override 1124 public void remove(Collection<CurrencyPK> pks) 1125 throws PersistenceDatabaseException { 1126 if(pks.size() > 0) { 1127 PreparedStatement _ps = session.prepareStatement(SQL_DELETE); 1128 int _modifiedEntities = 0; 1129 1130 try { 1131 for(CurrencyPK pk : pks) { 1132 long _entityId = pk.getEntityId(); 1133 1134 _ps.setLong(1, _entityId); 1135 1136 _ps.addBatch(); 1137 _modifiedEntities++; 1138 } 1139 1140 if(_modifiedEntities != 0) { 1141 if(PersistenceDebugFlags.CheckEntityDeleteRowCount) { 1142 int[] _counts = _ps.executeBatch(); 1143 1144 for(int _countOffset = 0 ; _countOffset < _modifiedEntities ; _countOffset++) { 1145 if(_counts[_countOffset] != 1 && _counts[_countOffset] != PreparedStatement.SUCCESS_NO_INFO) { 1146 throw new PersistenceDatabaseUpdateException("batch remove failed, _counts[" + _countOffset + "] = " + _counts[_countOffset]); 1147 } 1148 } 1149 } else { 1150 _ps.executeBatch(); 1151 } 1152 1153 _ps.clearBatch(); 1154 1155 pks.forEach((pk) -> { 1156 session.getValueCache().remove(pk); 1157 }); 1158 } 1159 } catch (SQLException se) { 1160 throw new PersistenceDatabaseException(se); 1161 } 1162 1163 pks.forEach((pk) -> { 1164 session.removed(pk, true); 1165 }); 1166 } 1167 } 1168 1169 @Override 1170 public boolean validPK(CurrencyPK pk) 1171 throws PersistenceDatabaseException { 1172 boolean valid = false; 1173 PreparedStatement _ps = session.prepareStatement(SQL_VALID); 1174 ResultSet _rs = null; 1175 1176 try { 1177 _ps.setLong(1, pk.getEntityId()); 1178 1179 _rs = _ps.executeQuery(); 1180 if(_rs.next()) { 1181 long _count = _rs.getLong(1); 1182 if(_rs.wasNull()) 1183 _count = 0; 1184 1185 if(_count == 1) 1186 valid = true; 1187 } 1188 } catch (SQLException se) { 1189 throw new PersistenceDatabaseException(se); 1190 } finally { 1191 if(_rs != null) { 1192 try { 1193 _rs.close(); 1194 } catch (SQLException se) { 1195 // do nothing 1196 } 1197 } 1198 } 1199 1200 return valid; 1201 } 1202 1203}