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