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