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