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