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