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 * DateTimeFormatDetailFactory.java 021 */ 022 023package com.echothree.model.data.party.server.factory; 024 025import com.echothree.model.data.party.common.pk.DateTimeFormatPK; 026 027import com.echothree.model.data.party.server.entity.DateTimeFormat; 028 029import com.echothree.model.data.party.common.DateTimeFormatDetailConstants; 030import com.echothree.model.data.party.common.pk.DateTimeFormatDetailPK; 031import com.echothree.model.data.party.server.value.DateTimeFormatDetailValue; 032import com.echothree.model.data.party.server.entity.DateTimeFormatDetail; 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 DateTimeFormatDetailFactory 062 implements BaseFactory<DateTimeFormatDetailPK, DateTimeFormatDetail> { 063 064 @Inject 065 Session session; 066 067 //private static final Logger log = LoggerFactory.getLogger(DateTimeFormatDetailFactory.class); 068 069 final private static String SQL_SELECT_READ_ONLY = "SELECT dtfdt_datetimeformatdetailid, dtfdt_dtf_datetimeformatid, dtfdt_datetimeformatname, dtfdt_javashortdateformat, dtfdt_javaabbrevdateformat, dtfdt_javaabbrevdateformatweekday, dtfdt_javalongdateformat, dtfdt_javalongdateformatweekday, dtfdt_javatimeformat, dtfdt_javatimeformatseconds, dtfdt_unixshortdateformat, dtfdt_unixabbrevdateformat, dtfdt_unixabbrevdateformatweekday, dtfdt_unixlongdateformat, dtfdt_unixlongdateformatweekday, dtfdt_unixtimeformat, dtfdt_unixtimeformatseconds, dtfdt_shortdateseparator, dtfdt_timeseparator, dtfdt_isdefault, dtfdt_sortorder, dtfdt_fromtime, dtfdt_thrutime FROM datetimeformatdetails WHERE dtfdt_datetimeformatdetailid = ?"; 070 final private static String SQL_SELECT_READ_WRITE = "SELECT dtfdt_datetimeformatdetailid, dtfdt_dtf_datetimeformatid, dtfdt_datetimeformatname, dtfdt_javashortdateformat, dtfdt_javaabbrevdateformat, dtfdt_javaabbrevdateformatweekday, dtfdt_javalongdateformat, dtfdt_javalongdateformatweekday, dtfdt_javatimeformat, dtfdt_javatimeformatseconds, dtfdt_unixshortdateformat, dtfdt_unixabbrevdateformat, dtfdt_unixabbrevdateformatweekday, dtfdt_unixlongdateformat, dtfdt_unixlongdateformatweekday, dtfdt_unixtimeformat, dtfdt_unixtimeformatseconds, dtfdt_shortdateseparator, dtfdt_timeseparator, dtfdt_isdefault, dtfdt_sortorder, dtfdt_fromtime, dtfdt_thrutime FROM datetimeformatdetails WHERE dtfdt_datetimeformatdetailid = ? FOR UPDATE"; 071 final private static String SQL_INSERT = "INSERT INTO datetimeformatdetails (dtfdt_datetimeformatdetailid, dtfdt_dtf_datetimeformatid, dtfdt_datetimeformatname, dtfdt_javashortdateformat, dtfdt_javaabbrevdateformat, dtfdt_javaabbrevdateformatweekday, dtfdt_javalongdateformat, dtfdt_javalongdateformatweekday, dtfdt_javatimeformat, dtfdt_javatimeformatseconds, dtfdt_unixshortdateformat, dtfdt_unixabbrevdateformat, dtfdt_unixabbrevdateformatweekday, dtfdt_unixlongdateformat, dtfdt_unixlongdateformatweekday, dtfdt_unixtimeformat, dtfdt_unixtimeformatseconds, dtfdt_shortdateseparator, dtfdt_timeseparator, dtfdt_isdefault, dtfdt_sortorder, dtfdt_fromtime, dtfdt_thrutime) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; 072 final private static String SQL_UPDATE = "UPDATE datetimeformatdetails SET dtfdt_dtf_datetimeformatid = ?, dtfdt_datetimeformatname = ?, dtfdt_javashortdateformat = ?, dtfdt_javaabbrevdateformat = ?, dtfdt_javaabbrevdateformatweekday = ?, dtfdt_javalongdateformat = ?, dtfdt_javalongdateformatweekday = ?, dtfdt_javatimeformat = ?, dtfdt_javatimeformatseconds = ?, dtfdt_unixshortdateformat = ?, dtfdt_unixabbrevdateformat = ?, dtfdt_unixabbrevdateformatweekday = ?, dtfdt_unixlongdateformat = ?, dtfdt_unixlongdateformatweekday = ?, dtfdt_unixtimeformat = ?, dtfdt_unixtimeformatseconds = ?, dtfdt_shortdateseparator = ?, dtfdt_timeseparator = ?, dtfdt_isdefault = ?, dtfdt_sortorder = ?, dtfdt_fromtime = ?, dtfdt_thrutime = ? WHERE dtfdt_datetimeformatdetailid = ?"; 073 final private static String SQL_DELETE = "DELETE FROM datetimeformatdetails WHERE dtfdt_datetimeformatdetailid = ?"; 074 final private static String SQL_VALID = "SELECT COUNT(*) FROM datetimeformatdetails WHERE dtfdt_datetimeformatdetailid = ?"; 075 076 final private static String PK_COLUMN = "dtfdt_datetimeformatdetailid"; 077 final private static String ALL_COLUMNS = "dtfdt_datetimeformatdetailid, dtfdt_dtf_datetimeformatid, dtfdt_datetimeformatname, dtfdt_javashortdateformat, dtfdt_javaabbrevdateformat, dtfdt_javaabbrevdateformatweekday, dtfdt_javalongdateformat, dtfdt_javalongdateformatweekday, dtfdt_javatimeformat, dtfdt_javatimeformatseconds, dtfdt_unixshortdateformat, dtfdt_unixabbrevdateformat, dtfdt_unixabbrevdateformatweekday, dtfdt_unixlongdateformat, dtfdt_unixlongdateformatweekday, dtfdt_unixtimeformat, dtfdt_unixtimeformatseconds, dtfdt_shortdateseparator, dtfdt_timeseparator, dtfdt_isdefault, dtfdt_sortorder, dtfdt_fromtime, dtfdt_thrutime"; 078 final public static String TABLE_NAME = "datetimeformatdetails"; 079 080 final public static String DTFDT_DATETIMEFORMATDETAILID = "dtfdt_datetimeformatdetailid"; 081 final public static String DTFDT_DTF_DATETIMEFORMATID = "dtfdt_dtf_datetimeformatid"; 082 final public static String DTFDT_DATETIMEFORMATNAME = "dtfdt_datetimeformatname"; 083 final public static String DTFDT_JAVASHORTDATEFORMAT = "dtfdt_javashortdateformat"; 084 final public static String DTFDT_JAVAABBREVDATEFORMAT = "dtfdt_javaabbrevdateformat"; 085 final public static String DTFDT_JAVAABBREVDATEFORMATWEEKDAY = "dtfdt_javaabbrevdateformatweekday"; 086 final public static String DTFDT_JAVALONGDATEFORMAT = "dtfdt_javalongdateformat"; 087 final public static String DTFDT_JAVALONGDATEFORMATWEEKDAY = "dtfdt_javalongdateformatweekday"; 088 final public static String DTFDT_JAVATIMEFORMAT = "dtfdt_javatimeformat"; 089 final public static String DTFDT_JAVATIMEFORMATSECONDS = "dtfdt_javatimeformatseconds"; 090 final public static String DTFDT_UNIXSHORTDATEFORMAT = "dtfdt_unixshortdateformat"; 091 final public static String DTFDT_UNIXABBREVDATEFORMAT = "dtfdt_unixabbrevdateformat"; 092 final public static String DTFDT_UNIXABBREVDATEFORMATWEEKDAY = "dtfdt_unixabbrevdateformatweekday"; 093 final public static String DTFDT_UNIXLONGDATEFORMAT = "dtfdt_unixlongdateformat"; 094 final public static String DTFDT_UNIXLONGDATEFORMATWEEKDAY = "dtfdt_unixlongdateformatweekday"; 095 final public static String DTFDT_UNIXTIMEFORMAT = "dtfdt_unixtimeformat"; 096 final public static String DTFDT_UNIXTIMEFORMATSECONDS = "dtfdt_unixtimeformatseconds"; 097 final public static String DTFDT_SHORTDATESEPARATOR = "dtfdt_shortdateseparator"; 098 final public static String DTFDT_TIMESEPARATOR = "dtfdt_timeseparator"; 099 final public static String DTFDT_ISDEFAULT = "dtfdt_isdefault"; 100 final public static String DTFDT_SORTORDER = "dtfdt_sortorder"; 101 final public static String DTFDT_FROMTIME = "dtfdt_fromtime"; 102 final public static String DTFDT_THRUTIME = "dtfdt_thrutime"; 103 104 final private static EntityIdGenerator entityIdGenerator = new EntityIdGenerator(DateTimeFormatDetailConstants.COMPONENT_VENDOR_NAME, DateTimeFormatDetailConstants.ENTITY_TYPE_NAME); 105 106 /** Creates a new instance of DateTimeFormatDetailFactory */ 107 protected DateTimeFormatDetailFactory() { 108 super(); 109 } 110 111 public static DateTimeFormatDetailFactory getInstance() { 112 return CDI.current().select(DateTimeFormatDetailFactory.class).get(); 113 } 114 115 @Override 116 public String getPKColumn() { 117 return PK_COLUMN; 118 } 119 120 @Override 121 public String getAllColumns() { 122 return ALL_COLUMNS; 123 } 124 125 @Override 126 public String getTableName() { 127 return TABLE_NAME; 128 } 129 130 @Override 131 public String getComponentVendorName() { 132 return DateTimeFormatDetailConstants.COMPONENT_VENDOR_NAME; 133 } 134 135 @Override 136 public String getEntityTypeName() { 137 return DateTimeFormatDetailConstants.ENTITY_TYPE_NAME; 138 } 139 140 public PreparedStatement prepareStatement(String query) { 141 return session.prepareStatement(DateTimeFormatDetailFactory.class, query); 142 } 143 144 public DateTimeFormatDetailPK getNextPK() { 145 return new DateTimeFormatDetailPK(entityIdGenerator.getNextEntityId()); 146 } 147 148 public Set<DateTimeFormatDetailPK> getPKsFromResultSetAsSet(ResultSet rs) 149 throws PersistenceDatabaseException { 150 Set<DateTimeFormatDetailPK> _result = new HashSet<>(); 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 java.util.List<DateTimeFormatDetailPK> getPKsFromResultSetAsList(ResultSet rs) 164 throws PersistenceDatabaseException { 165 java.util.List<DateTimeFormatDetailPK> _result = new ArrayList<>(); 166 167 try { 168 while(rs.next()) { 169 _result.add(getPKFromResultSet(rs)); 170 } 171 } catch (SQLException se) { 172 throw new PersistenceDatabaseException(se); 173 } 174 175 return _result; 176 } 177 178 public DateTimeFormatDetailPK getPKFromResultSet(ResultSet rs) 179 throws PersistenceDatabaseException { 180 DateTimeFormatDetailPK _result; 181 182 try { 183 long dtfdt_datetimeformatdetailid = rs.getLong(DTFDT_DATETIMEFORMATDETAILID); 184 Long _entityId = rs.wasNull() ? null : dtfdt_datetimeformatdetailid; 185 186 _result = new DateTimeFormatDetailPK(_entityId); 187 } catch (SQLException se) { 188 throw new PersistenceDatabaseException(se); 189 } 190 191 return _result; 192 } 193 194 public java.util.List<DateTimeFormatDetailValue> getValuesFromPKs(Collection<DateTimeFormatDetailPK> pks) 195 throws PersistenceDatabaseException { 196 java.util.List<DateTimeFormatDetailValue> _values = new ArrayList<>(pks.size()); 197 198 for(DateTimeFormatDetailPK _pk: pks) { 199 _values.add(getValueFromPK(_pk)); 200 } 201 202 return _values; 203 } 204 205 public DateTimeFormatDetailValue getValueFromPK(DateTimeFormatDetailPK pk) 206 throws PersistenceDatabaseException { 207 DateTimeFormatDetailValue _value; 208 209 // See if we already have the entity in the session cache 210 DateTimeFormatDetail _entity = (DateTimeFormatDetail)session.getEntity(pk); 211 if(_entity == null) 212 _value = getEntityFromPK(EntityPermission.READ_ONLY, pk).getDateTimeFormatDetailValue(); 213 else 214 _value = _entity.getDateTimeFormatDetailValue(); 215 216 return _value; 217 } 218 219 public java.util.List<DateTimeFormatDetailValue> getValuesFromResultSet(ResultSet rs) 220 throws PersistenceDatabaseException { 221 java.util.List<DateTimeFormatDetailValue> _result = new ArrayList<>(); 222 223 try { 224 while(rs.next()) { 225 _result.add(getValueFromResultSet(rs)); 226 } 227 } catch (SQLException se) { 228 throw new PersistenceDatabaseException(se); 229 } 230 231 return _result; 232 } 233 234 public DateTimeFormatDetailValue getValueFromResultSet(ResultSet rs) 235 throws PersistenceDatabaseException { 236 DateTimeFormatDetailValue _value; 237 238 try { 239 Long dtfdt_datetimeformatdetailid = rs.getLong(DTFDT_DATETIMEFORMATDETAILID); 240 DateTimeFormatDetailPK _pk = new DateTimeFormatDetailPK(dtfdt_datetimeformatdetailid); 241 242 // See if we already have the entity in the session cache 243 DateTimeFormatDetail _entity = (DateTimeFormatDetail)session.getEntity(_pk); 244 245 if(_entity == null) { 246 Long dtfdt_dtf_datetimeformatid = rs.getLong(DTFDT_DTF_DATETIMEFORMATID); 247 if(rs.wasNull()) 248 dtfdt_dtf_datetimeformatid = null; 249 250 String dtfdt_datetimeformatname = rs.getString(DTFDT_DATETIMEFORMATNAME); 251 if(rs.wasNull()) 252 dtfdt_datetimeformatname = null; 253 254 String dtfdt_javashortdateformat = rs.getString(DTFDT_JAVASHORTDATEFORMAT); 255 if(rs.wasNull()) 256 dtfdt_javashortdateformat = null; 257 258 String dtfdt_javaabbrevdateformat = rs.getString(DTFDT_JAVAABBREVDATEFORMAT); 259 if(rs.wasNull()) 260 dtfdt_javaabbrevdateformat = null; 261 262 String dtfdt_javaabbrevdateformatweekday = rs.getString(DTFDT_JAVAABBREVDATEFORMATWEEKDAY); 263 if(rs.wasNull()) 264 dtfdt_javaabbrevdateformatweekday = null; 265 266 String dtfdt_javalongdateformat = rs.getString(DTFDT_JAVALONGDATEFORMAT); 267 if(rs.wasNull()) 268 dtfdt_javalongdateformat = null; 269 270 String dtfdt_javalongdateformatweekday = rs.getString(DTFDT_JAVALONGDATEFORMATWEEKDAY); 271 if(rs.wasNull()) 272 dtfdt_javalongdateformatweekday = null; 273 274 String dtfdt_javatimeformat = rs.getString(DTFDT_JAVATIMEFORMAT); 275 if(rs.wasNull()) 276 dtfdt_javatimeformat = null; 277 278 String dtfdt_javatimeformatseconds = rs.getString(DTFDT_JAVATIMEFORMATSECONDS); 279 if(rs.wasNull()) 280 dtfdt_javatimeformatseconds = null; 281 282 String dtfdt_unixshortdateformat = rs.getString(DTFDT_UNIXSHORTDATEFORMAT); 283 if(rs.wasNull()) 284 dtfdt_unixshortdateformat = null; 285 286 String dtfdt_unixabbrevdateformat = rs.getString(DTFDT_UNIXABBREVDATEFORMAT); 287 if(rs.wasNull()) 288 dtfdt_unixabbrevdateformat = null; 289 290 String dtfdt_unixabbrevdateformatweekday = rs.getString(DTFDT_UNIXABBREVDATEFORMATWEEKDAY); 291 if(rs.wasNull()) 292 dtfdt_unixabbrevdateformatweekday = null; 293 294 String dtfdt_unixlongdateformat = rs.getString(DTFDT_UNIXLONGDATEFORMAT); 295 if(rs.wasNull()) 296 dtfdt_unixlongdateformat = null; 297 298 String dtfdt_unixlongdateformatweekday = rs.getString(DTFDT_UNIXLONGDATEFORMATWEEKDAY); 299 if(rs.wasNull()) 300 dtfdt_unixlongdateformatweekday = null; 301 302 String dtfdt_unixtimeformat = rs.getString(DTFDT_UNIXTIMEFORMAT); 303 if(rs.wasNull()) 304 dtfdt_unixtimeformat = null; 305 306 String dtfdt_unixtimeformatseconds = rs.getString(DTFDT_UNIXTIMEFORMATSECONDS); 307 if(rs.wasNull()) 308 dtfdt_unixtimeformatseconds = null; 309 310 String dtfdt_shortdateseparator = rs.getString(DTFDT_SHORTDATESEPARATOR); 311 if(rs.wasNull()) 312 dtfdt_shortdateseparator = null; 313 314 String dtfdt_timeseparator = rs.getString(DTFDT_TIMESEPARATOR); 315 if(rs.wasNull()) 316 dtfdt_timeseparator = null; 317 318 Boolean dtfdt_isdefault = rs.getInt(DTFDT_ISDEFAULT) == 1; 319 if(rs.wasNull()) 320 dtfdt_isdefault = null; 321 322 Integer dtfdt_sortorder = rs.getInt(DTFDT_SORTORDER); 323 if(rs.wasNull()) 324 dtfdt_sortorder = null; 325 326 Long dtfdt_fromtime = rs.getLong(DTFDT_FROMTIME); 327 if(rs.wasNull()) 328 dtfdt_fromtime = null; 329 330 Long dtfdt_thrutime = rs.getLong(DTFDT_THRUTIME); 331 if(rs.wasNull()) 332 dtfdt_thrutime = null; 333 334 _value = new DateTimeFormatDetailValue(_pk, new DateTimeFormatPK(dtfdt_dtf_datetimeformatid), dtfdt_datetimeformatname, dtfdt_javashortdateformat, dtfdt_javaabbrevdateformat, dtfdt_javaabbrevdateformatweekday, dtfdt_javalongdateformat, dtfdt_javalongdateformatweekday, dtfdt_javatimeformat, dtfdt_javatimeformatseconds, dtfdt_unixshortdateformat, dtfdt_unixabbrevdateformat, dtfdt_unixabbrevdateformatweekday, dtfdt_unixlongdateformat, dtfdt_unixlongdateformatweekday, dtfdt_unixtimeformat, dtfdt_unixtimeformatseconds, dtfdt_shortdateseparator, dtfdt_timeseparator, dtfdt_isdefault, dtfdt_sortorder, dtfdt_fromtime, dtfdt_thrutime); 335 } else 336 _value = _entity.getDateTimeFormatDetailValue(); 337 } catch (SQLException se) { 338 throw new PersistenceDatabaseException(se); 339 } 340 341 return _value; 342 } 343 344 public java.util.List<DateTimeFormatDetail> getEntitiesFromPKs(EntityPermission entityPermission, Collection<DateTimeFormatDetailPK> pks) 345 throws PersistenceDatabaseException { 346 java.util.List<DateTimeFormatDetail> _entities = new ArrayList<>(pks.size()); 347 348 for(DateTimeFormatDetailPK _pk: pks) { 349 _entities.add(getEntityFromPK(entityPermission, _pk)); 350 } 351 352 return _entities; 353 } 354 355 public DateTimeFormatDetail getEntityFromValue(EntityPermission entityPermission, DateTimeFormatDetailValue value) { 356 return getEntityFromPK(entityPermission, value.getPrimaryKey()); 357 } 358 359 public DateTimeFormatDetail getEntityFromCache(DateTimeFormatDetailPK pk) { 360 DateTimeFormatDetailValue _value = (DateTimeFormatDetailValue)session.getValueCache().get(pk); 361 362 return _value == null ? null : new DateTimeFormatDetail(_value, EntityPermission.READ_ONLY); 363 } 364 365 public DateTimeFormatDetail getEntityFromPK(EntityPermission entityPermission, DateTimeFormatDetailPK pk) 366 throws PersistenceDatabaseException { 367 DateTimeFormatDetail _entity; 368 369 // See if we already have the entity in the session cache 370 _entity = (DateTimeFormatDetail)session.getEntity(pk); 371 if(_entity != null) { 372 // If the requested permission is READ_WRITE, and the cached permission is 373 // READ_ONLY, then pretend that the cached object wasn't found, and create 374 // a new entity that is READ_WRITE. 375 if(entityPermission.equals(EntityPermission.READ_WRITE)) { 376 if(_entity.getEntityPermission().equals(EntityPermission.READ_ONLY)) 377 _entity = null; 378 } 379 } 380 381 if(_entity == null && entityPermission.equals(EntityPermission.READ_ONLY)) { 382 _entity = getEntityFromCache(pk); 383 } 384 385 if(_entity == null) { 386 PreparedStatement _ps = session.prepareStatement(entityPermission.equals(EntityPermission.READ_ONLY)? SQL_SELECT_READ_ONLY: SQL_SELECT_READ_WRITE); 387 long _entityId = pk.getEntityId(); 388 ResultSet _rs = null; 389 390 try { 391 _ps.setLong(1, _entityId); 392 _rs = _ps.executeQuery(); 393 if(_rs.next()) { 394 _entity = getEntityFromResultSet(entityPermission, _rs); 395 } 396 } catch (SQLException se) { 397 throw new PersistenceDatabaseException(se); 398 } finally { 399 if(_rs != null) { 400 try { 401 _rs.close(); 402 } catch (SQLException se) { 403 // do nothing 404 } 405 } 406 } 407 } 408 409 return _entity; 410 } 411 412 public Set<DateTimeFormatDetailPK> getPKsFromQueryAsSet(PreparedStatement ps, final Object... params) 413 throws PersistenceDatabaseException { 414 Set<DateTimeFormatDetailPK> _pks; 415 ResultSet _rs = null; 416 417 try { 418 if(params.length != 0) { 419 Session.setQueryParams(ps, params); 420 } 421 422 _rs = ps.executeQuery(); 423 _pks = getPKsFromResultSetAsSet(_rs); 424 _rs.close(); 425 } catch (SQLException se) { 426 throw new PersistenceDatabaseException(se); 427 } finally { 428 if(_rs != null) { 429 try { 430 _rs.close(); 431 } catch (SQLException se) { 432 // do nothing 433 } 434 } 435 } 436 437 return _pks; 438 } 439 440 public java.util.List<DateTimeFormatDetailPK> getPKsFromQueryAsList(PreparedStatement ps, final Object... params) 441 throws PersistenceDatabaseException { 442 java.util.List<DateTimeFormatDetailPK> _pks; 443 ResultSet _rs = null; 444 445 try { 446 if(params.length != 0) { 447 Session.setQueryParams(ps, params); 448 } 449 450 _rs = ps.executeQuery(); 451 _pks = getPKsFromResultSetAsList(_rs); 452 _rs.close(); 453 } catch (SQLException se) { 454 throw new PersistenceDatabaseException(se); 455 } finally { 456 if(_rs != null) { 457 try { 458 _rs.close(); 459 } catch (SQLException se) { 460 // do nothing 461 } 462 } 463 } 464 465 return _pks; 466 } 467 468 public DateTimeFormatDetailPK getPKFromQuery(PreparedStatement ps, final Object... params) 469 throws PersistenceDatabaseException { 470 DateTimeFormatDetailPK _pk = null; 471 ResultSet _rs = null; 472 473 try { 474 if(params.length != 0) { 475 Session.setQueryParams(ps, params); 476 } 477 478 _rs = ps.executeQuery(); 479 if(_rs.next()) { 480 _pk = getPKFromResultSet(_rs); 481 } 482 _rs.close(); 483 } catch (SQLException se) { 484 throw new PersistenceDatabaseException(se); 485 } finally { 486 if(_rs != null) { 487 try { 488 _rs.close(); 489 } catch (SQLException se) { 490 // do nothing 491 } 492 } 493 } 494 495 return _pk; 496 } 497 498 public java.util.List<DateTimeFormatDetail> getEntitiesFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap, final Object... params) 499 throws PersistenceDatabaseException { 500 PreparedStatement ps = session.prepareStatement(DateTimeFormatDetailFactory.class, queryMap.get(entityPermission)); 501 502 return getEntitiesFromQuery(entityPermission, ps, params); 503 } 504 505 public java.util.List<DateTimeFormatDetail> getEntitiesFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap) 506 throws PersistenceDatabaseException { 507 PreparedStatement ps = session.prepareStatement(DateTimeFormatDetailFactory.class, queryMap.get(entityPermission)); 508 509 return getEntitiesFromQuery(entityPermission, ps); 510 } 511 512 public java.util.List<DateTimeFormatDetail> getEntitiesFromQuery(EntityPermission entityPermission, ResultQuery<?> query) 513 throws PersistenceDatabaseException { 514 PreparedStatement ps = session.prepareStatement(DateTimeFormatDetailFactory.class, query.getSQL()); 515 516 return getEntitiesFromQuery(entityPermission, ps, query.getBindValues().toArray()); 517 } 518 519 public java.util.List<DateTimeFormatDetail> getEntitiesFromQuery(EntityPermission entityPermission, PreparedStatement ps, final Object... params) 520 throws PersistenceDatabaseException { 521 java.util.List<DateTimeFormatDetail> _entities; 522 ResultSet _rs = null; 523 524 try { 525 if(params.length != 0) { 526 Session.setQueryParams(ps, params); 527 } 528 529 _rs = ps.executeQuery(); 530 _entities = getEntitiesFromResultSet(entityPermission, _rs); 531 _rs.close(); 532 } catch (SQLException se) { 533 throw new PersistenceDatabaseException(se); 534 } finally { 535 if(_rs != null) { 536 try { 537 _rs.close(); 538 } catch (SQLException se) { 539 // do nothing 540 } 541 } 542 } 543 544 return _entities; 545 } 546 547 public DateTimeFormatDetail getEntityFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap, final Object... params) 548 throws PersistenceDatabaseException { 549 PreparedStatement ps = session.prepareStatement(DateTimeFormatDetailFactory.class, queryMap.get(entityPermission)); 550 551 return getEntityFromQuery(entityPermission, ps, params); 552 } 553 554 public DateTimeFormatDetail getEntityFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap) 555 throws PersistenceDatabaseException { 556 PreparedStatement ps = session.prepareStatement(DateTimeFormatDetailFactory.class, queryMap.get(entityPermission)); 557 558 return getEntityFromQuery(entityPermission, ps); 559 } 560 561 public DateTimeFormatDetail getEntityFromQuery(EntityPermission entityPermission, ResultQuery<?> query) 562 throws PersistenceDatabaseException { 563 PreparedStatement ps = session.prepareStatement(DateTimeFormatDetailFactory.class, query.getSQL()); 564 565 return getEntityFromQuery(entityPermission, ps, query.getBindValues().toArray()); 566 } 567 568 public DateTimeFormatDetail getEntityFromQuery(EntityPermission entityPermission, PreparedStatement ps, final Object... params) 569 throws PersistenceDatabaseException { 570 DateTimeFormatDetail _entity = null; 571 ResultSet _rs = null; 572 573 try { 574 if(params.length != 0) { 575 Session.setQueryParams(ps, params); 576 } 577 578 _rs = ps.executeQuery(); 579 if(_rs.next()) { 580 _entity = getEntityFromResultSet(entityPermission, _rs); 581 } 582 _rs.close(); 583 } catch (SQLException se) { 584 throw new PersistenceDatabaseException(se); 585 } finally { 586 if(_rs != null) { 587 try { 588 _rs.close(); 589 } catch (SQLException se) { 590 // do nothing 591 } 592 } 593 } 594 595 return _entity; 596 } 597 598 public java.util.List<DateTimeFormatDetail> getEntitiesFromResultSet(EntityPermission entityPermission, ResultSet rs) 599 throws PersistenceDatabaseException { 600 java.util.List<DateTimeFormatDetail> _result = new ArrayList<>(); 601 602 try { 603 while(rs.next()) { 604 _result.add(getEntityFromResultSet(entityPermission, rs)); 605 } 606 } catch (SQLException se) { 607 throw new PersistenceDatabaseException(se); 608 } 609 610 return _result; 611 } 612 613 public DateTimeFormatDetail getEntityFromResultSet(EntityPermission entityPermission, ResultSet rs) 614 throws PersistenceDatabaseException { 615 DateTimeFormatDetail _entity; 616 617 try { 618 Long dtfdt_datetimeformatdetailid = rs.getLong(DTFDT_DATETIMEFORMATDETAILID); 619 DateTimeFormatDetailPK _pk = new DateTimeFormatDetailPK(dtfdt_datetimeformatdetailid); 620 621 // See if we already have the entity in the session cache 622 _entity = (DateTimeFormatDetail)session.getEntity(_pk); 623 if(_entity != null) { 624 // If the requested permission is READ_WRITE, and the cached permission is 625 // READ_ONLY, then pretend that the cached object wasn't found, and create 626 // a new entity that is READ_WRITE. 627 if(entityPermission.equals(EntityPermission.READ_WRITE)) { 628 if(_entity.getEntityPermission().equals(EntityPermission.READ_ONLY)) 629 _entity = null; 630 } 631 } 632 boolean foundInSessionCache = _entity != null; 633 634 if(_entity == null && entityPermission.equals(EntityPermission.READ_ONLY)) { 635 _entity = getEntityFromCache(_pk); 636 } 637 638 if(_entity == null) { 639 Long dtfdt_dtf_datetimeformatid = rs.getLong(DTFDT_DTF_DATETIMEFORMATID); 640 if(rs.wasNull()) 641 dtfdt_dtf_datetimeformatid = null; 642 643 String dtfdt_datetimeformatname = rs.getString(DTFDT_DATETIMEFORMATNAME); 644 if(rs.wasNull()) 645 dtfdt_datetimeformatname = null; 646 647 String dtfdt_javashortdateformat = rs.getString(DTFDT_JAVASHORTDATEFORMAT); 648 if(rs.wasNull()) 649 dtfdt_javashortdateformat = null; 650 651 String dtfdt_javaabbrevdateformat = rs.getString(DTFDT_JAVAABBREVDATEFORMAT); 652 if(rs.wasNull()) 653 dtfdt_javaabbrevdateformat = null; 654 655 String dtfdt_javaabbrevdateformatweekday = rs.getString(DTFDT_JAVAABBREVDATEFORMATWEEKDAY); 656 if(rs.wasNull()) 657 dtfdt_javaabbrevdateformatweekday = null; 658 659 String dtfdt_javalongdateformat = rs.getString(DTFDT_JAVALONGDATEFORMAT); 660 if(rs.wasNull()) 661 dtfdt_javalongdateformat = null; 662 663 String dtfdt_javalongdateformatweekday = rs.getString(DTFDT_JAVALONGDATEFORMATWEEKDAY); 664 if(rs.wasNull()) 665 dtfdt_javalongdateformatweekday = null; 666 667 String dtfdt_javatimeformat = rs.getString(DTFDT_JAVATIMEFORMAT); 668 if(rs.wasNull()) 669 dtfdt_javatimeformat = null; 670 671 String dtfdt_javatimeformatseconds = rs.getString(DTFDT_JAVATIMEFORMATSECONDS); 672 if(rs.wasNull()) 673 dtfdt_javatimeformatseconds = null; 674 675 String dtfdt_unixshortdateformat = rs.getString(DTFDT_UNIXSHORTDATEFORMAT); 676 if(rs.wasNull()) 677 dtfdt_unixshortdateformat = null; 678 679 String dtfdt_unixabbrevdateformat = rs.getString(DTFDT_UNIXABBREVDATEFORMAT); 680 if(rs.wasNull()) 681 dtfdt_unixabbrevdateformat = null; 682 683 String dtfdt_unixabbrevdateformatweekday = rs.getString(DTFDT_UNIXABBREVDATEFORMATWEEKDAY); 684 if(rs.wasNull()) 685 dtfdt_unixabbrevdateformatweekday = null; 686 687 String dtfdt_unixlongdateformat = rs.getString(DTFDT_UNIXLONGDATEFORMAT); 688 if(rs.wasNull()) 689 dtfdt_unixlongdateformat = null; 690 691 String dtfdt_unixlongdateformatweekday = rs.getString(DTFDT_UNIXLONGDATEFORMATWEEKDAY); 692 if(rs.wasNull()) 693 dtfdt_unixlongdateformatweekday = null; 694 695 String dtfdt_unixtimeformat = rs.getString(DTFDT_UNIXTIMEFORMAT); 696 if(rs.wasNull()) 697 dtfdt_unixtimeformat = null; 698 699 String dtfdt_unixtimeformatseconds = rs.getString(DTFDT_UNIXTIMEFORMATSECONDS); 700 if(rs.wasNull()) 701 dtfdt_unixtimeformatseconds = null; 702 703 String dtfdt_shortdateseparator = rs.getString(DTFDT_SHORTDATESEPARATOR); 704 if(rs.wasNull()) 705 dtfdt_shortdateseparator = null; 706 707 String dtfdt_timeseparator = rs.getString(DTFDT_TIMESEPARATOR); 708 if(rs.wasNull()) 709 dtfdt_timeseparator = null; 710 711 Boolean dtfdt_isdefault = rs.getInt(DTFDT_ISDEFAULT) == 1; 712 if(rs.wasNull()) 713 dtfdt_isdefault = null; 714 715 Integer dtfdt_sortorder = rs.getInt(DTFDT_SORTORDER); 716 if(rs.wasNull()) 717 dtfdt_sortorder = null; 718 719 Long dtfdt_fromtime = rs.getLong(DTFDT_FROMTIME); 720 if(rs.wasNull()) 721 dtfdt_fromtime = null; 722 723 Long dtfdt_thrutime = rs.getLong(DTFDT_THRUTIME); 724 if(rs.wasNull()) 725 dtfdt_thrutime = null; 726 727 DateTimeFormatDetailValue _value = new DateTimeFormatDetailValue(_pk, dtfdt_dtf_datetimeformatid == null? null: new DateTimeFormatPK(dtfdt_dtf_datetimeformatid), dtfdt_datetimeformatname, dtfdt_javashortdateformat, dtfdt_javaabbrevdateformat, dtfdt_javaabbrevdateformatweekday, dtfdt_javalongdateformat, dtfdt_javalongdateformatweekday, dtfdt_javatimeformat, dtfdt_javatimeformatseconds, dtfdt_unixshortdateformat, dtfdt_unixabbrevdateformat, dtfdt_unixabbrevdateformatweekday, dtfdt_unixlongdateformat, dtfdt_unixlongdateformatweekday, dtfdt_unixtimeformat, dtfdt_unixtimeformatseconds, dtfdt_shortdateseparator, dtfdt_timeseparator, dtfdt_isdefault, dtfdt_sortorder, dtfdt_fromtime, dtfdt_thrutime); 728 _entity = new DateTimeFormatDetail(_value, entityPermission); 729 } 730 731 if(!foundInSessionCache) { 732 if(entityPermission.equals(EntityPermission.READ_ONLY)) { 733 session.putReadOnlyEntity(_pk, _entity); 734 session.getValueCache().put(_entity.getDateTimeFormatDetailValue()); 735 } else { 736 session.putReadWriteEntity(_pk, _entity); 737 } 738 } 739 } catch (SQLException se) { 740 throw new PersistenceDatabaseException(se); 741 } 742 743 return _entity; 744 } 745 746 public DateTimeFormatDetail create(DateTimeFormat dateTimeFormat, String dateTimeFormatName, String javaShortDateFormat, String javaAbbrevDateFormat, String javaAbbrevDateFormatWeekday, String javaLongDateFormat, String javaLongDateFormatWeekday, String javaTimeFormat, String javaTimeFormatSeconds, String unixShortDateFormat, String unixAbbrevDateFormat, String unixAbbrevDateFormatWeekday, String unixLongDateFormat, String unixLongDateFormatWeekday, String unixTimeFormat, String unixTimeFormatSeconds, String shortDateSeparator, String timeSeparator, Boolean isDefault, Integer sortOrder, Long fromTime, Long thruTime) 747 throws PersistenceDatabaseException, PersistenceNotNullException { 748 return create(dateTimeFormat == null ? null : dateTimeFormat.getPrimaryKey(), dateTimeFormatName, javaShortDateFormat, javaAbbrevDateFormat, javaAbbrevDateFormatWeekday, javaLongDateFormat, javaLongDateFormatWeekday, javaTimeFormat, javaTimeFormatSeconds, unixShortDateFormat, unixAbbrevDateFormat, unixAbbrevDateFormatWeekday, unixLongDateFormat, unixLongDateFormatWeekday, unixTimeFormat, unixTimeFormatSeconds, shortDateSeparator, timeSeparator, isDefault, sortOrder, fromTime, thruTime); 749 } 750 751 private void bindForCreate(PreparedStatement _ps, DateTimeFormatDetailValue _value) 752 throws SQLException { 753 _ps.setLong(1, _value.getEntityId()); 754 755 DateTimeFormatPK dtfdt_dtf_datetimeformatid = _value.getDateTimeFormatPK(); 756 if(dtfdt_dtf_datetimeformatid == null) 757 _ps.setNull(2, Types.BIGINT); 758 else 759 _ps.setLong(2, dtfdt_dtf_datetimeformatid.getEntityId()); 760 761 String dtfdt_datetimeformatname = _value.getDateTimeFormatName(); 762 if(dtfdt_datetimeformatname == null) 763 _ps.setNull(3, Types.VARCHAR); 764 else 765 _ps.setString(3, dtfdt_datetimeformatname); 766 767 String dtfdt_javashortdateformat = _value.getJavaShortDateFormat(); 768 if(dtfdt_javashortdateformat == null) 769 _ps.setNull(4, Types.VARCHAR); 770 else 771 _ps.setString(4, dtfdt_javashortdateformat); 772 773 String dtfdt_javaabbrevdateformat = _value.getJavaAbbrevDateFormat(); 774 if(dtfdt_javaabbrevdateformat == null) 775 _ps.setNull(5, Types.VARCHAR); 776 else 777 _ps.setString(5, dtfdt_javaabbrevdateformat); 778 779 String dtfdt_javaabbrevdateformatweekday = _value.getJavaAbbrevDateFormatWeekday(); 780 if(dtfdt_javaabbrevdateformatweekday == null) 781 _ps.setNull(6, Types.VARCHAR); 782 else 783 _ps.setString(6, dtfdt_javaabbrevdateformatweekday); 784 785 String dtfdt_javalongdateformat = _value.getJavaLongDateFormat(); 786 if(dtfdt_javalongdateformat == null) 787 _ps.setNull(7, Types.VARCHAR); 788 else 789 _ps.setString(7, dtfdt_javalongdateformat); 790 791 String dtfdt_javalongdateformatweekday = _value.getJavaLongDateFormatWeekday(); 792 if(dtfdt_javalongdateformatweekday == null) 793 _ps.setNull(8, Types.VARCHAR); 794 else 795 _ps.setString(8, dtfdt_javalongdateformatweekday); 796 797 String dtfdt_javatimeformat = _value.getJavaTimeFormat(); 798 if(dtfdt_javatimeformat == null) 799 _ps.setNull(9, Types.VARCHAR); 800 else 801 _ps.setString(9, dtfdt_javatimeformat); 802 803 String dtfdt_javatimeformatseconds = _value.getJavaTimeFormatSeconds(); 804 if(dtfdt_javatimeformatseconds == null) 805 _ps.setNull(10, Types.VARCHAR); 806 else 807 _ps.setString(10, dtfdt_javatimeformatseconds); 808 809 String dtfdt_unixshortdateformat = _value.getUnixShortDateFormat(); 810 if(dtfdt_unixshortdateformat == null) 811 _ps.setNull(11, Types.VARCHAR); 812 else 813 _ps.setString(11, dtfdt_unixshortdateformat); 814 815 String dtfdt_unixabbrevdateformat = _value.getUnixAbbrevDateFormat(); 816 if(dtfdt_unixabbrevdateformat == null) 817 _ps.setNull(12, Types.VARCHAR); 818 else 819 _ps.setString(12, dtfdt_unixabbrevdateformat); 820 821 String dtfdt_unixabbrevdateformatweekday = _value.getUnixAbbrevDateFormatWeekday(); 822 if(dtfdt_unixabbrevdateformatweekday == null) 823 _ps.setNull(13, Types.VARCHAR); 824 else 825 _ps.setString(13, dtfdt_unixabbrevdateformatweekday); 826 827 String dtfdt_unixlongdateformat = _value.getUnixLongDateFormat(); 828 if(dtfdt_unixlongdateformat == null) 829 _ps.setNull(14, Types.VARCHAR); 830 else 831 _ps.setString(14, dtfdt_unixlongdateformat); 832 833 String dtfdt_unixlongdateformatweekday = _value.getUnixLongDateFormatWeekday(); 834 if(dtfdt_unixlongdateformatweekday == null) 835 _ps.setNull(15, Types.VARCHAR); 836 else 837 _ps.setString(15, dtfdt_unixlongdateformatweekday); 838 839 String dtfdt_unixtimeformat = _value.getUnixTimeFormat(); 840 if(dtfdt_unixtimeformat == null) 841 _ps.setNull(16, Types.VARCHAR); 842 else 843 _ps.setString(16, dtfdt_unixtimeformat); 844 845 String dtfdt_unixtimeformatseconds = _value.getUnixTimeFormatSeconds(); 846 if(dtfdt_unixtimeformatseconds == null) 847 _ps.setNull(17, Types.VARCHAR); 848 else 849 _ps.setString(17, dtfdt_unixtimeformatseconds); 850 851 String dtfdt_shortdateseparator = _value.getShortDateSeparator(); 852 if(dtfdt_shortdateseparator == null) 853 _ps.setNull(18, Types.VARCHAR); 854 else 855 _ps.setString(18, dtfdt_shortdateseparator); 856 857 String dtfdt_timeseparator = _value.getTimeSeparator(); 858 if(dtfdt_timeseparator == null) 859 _ps.setNull(19, Types.VARCHAR); 860 else 861 _ps.setString(19, dtfdt_timeseparator); 862 863 Boolean dtfdt_isdefault = _value.getIsDefault(); 864 if(dtfdt_isdefault == null) 865 _ps.setNull(20, Types.BIT); 866 else 867 _ps.setInt(20, dtfdt_isdefault? 1: 0); 868 869 Integer dtfdt_sortorder = _value.getSortOrder(); 870 if(dtfdt_sortorder == null) 871 _ps.setNull(21, Types.INTEGER); 872 else 873 _ps.setInt(21, dtfdt_sortorder); 874 875 Long dtfdt_fromtime = _value.getFromTime(); 876 if(dtfdt_fromtime == null) 877 _ps.setNull(22, Types.BIGINT); 878 else 879 _ps.setLong(22, dtfdt_fromtime); 880 881 Long dtfdt_thrutime = _value.getThruTime(); 882 if(dtfdt_thrutime == null) 883 _ps.setNull(23, Types.BIGINT); 884 else 885 _ps.setLong(23, dtfdt_thrutime); 886 887 } 888 889 public DateTimeFormatDetail create(DateTimeFormatPK dateTimeFormatPK, String dateTimeFormatName, String javaShortDateFormat, String javaAbbrevDateFormat, String javaAbbrevDateFormatWeekday, String javaLongDateFormat, String javaLongDateFormatWeekday, String javaTimeFormat, String javaTimeFormatSeconds, String unixShortDateFormat, String unixAbbrevDateFormat, String unixAbbrevDateFormatWeekday, String unixLongDateFormat, String unixLongDateFormatWeekday, String unixTimeFormat, String unixTimeFormatSeconds, String shortDateSeparator, String timeSeparator, Boolean isDefault, Integer sortOrder, Long fromTime, Long thruTime) 890 throws PersistenceDatabaseException, PersistenceNotNullException { 891 DateTimeFormatDetailPK _pk = getNextPK(); 892 DateTimeFormatDetailValue _value = new DateTimeFormatDetailValue(_pk, dateTimeFormatPK, dateTimeFormatName, javaShortDateFormat, javaAbbrevDateFormat, javaAbbrevDateFormatWeekday, javaLongDateFormat, javaLongDateFormatWeekday, javaTimeFormat, javaTimeFormatSeconds, unixShortDateFormat, unixAbbrevDateFormat, unixAbbrevDateFormatWeekday, unixLongDateFormat, unixLongDateFormatWeekday, unixTimeFormat, unixTimeFormatSeconds, shortDateSeparator, timeSeparator, isDefault, sortOrder, fromTime, thruTime); 893 894 PreparedStatement _ps = session.prepareStatement(SQL_INSERT); 895 896 try { 897 bindForCreate(_ps, _value); 898 899 if(PersistenceDebugFlags.CheckEntityInsertRowCount) { 900 int _count = _ps.executeUpdate(); 901 902 if(_count != 1) { 903 throw new PersistenceDatabaseUpdateException("insert failed, _count = " + _count); 904 } 905 } else { 906 _ps.executeUpdate(); 907 } 908 909 session.getValueCache().put(_value); 910 } catch (SQLException se) { 911 throw new PersistenceDatabaseException(se); 912 } 913 914 DateTimeFormatDetail _entity = new DateTimeFormatDetail(_value, EntityPermission.READ_ONLY); 915 session.putReadOnlyEntity(_pk, _entity); 916 917 return _entity; 918 } 919 920 public void create(Collection<DateTimeFormatDetailValue> _values) 921 throws PersistenceDatabaseException, PersistenceNotNullException { 922 int _size = _values.size(); 923 924 if(_size > 0) { 925 PreparedStatement _ps = session.prepareStatement(SQL_INSERT); 926 List<DateTimeFormatDetailValue> _cacheValues = new ArrayList<>(_size); 927 928 try { 929 for(DateTimeFormatDetailValue _value : _values) { 930 _value.setEntityId(entityIdGenerator.getNextEntityId()); 931 bindForCreate(_ps, _value); 932 933 _ps.addBatch(); 934 935 _cacheValues.add(_value); 936 } 937 938 if(PersistenceDebugFlags.CheckEntityInsertRowCount) { 939 int[] _counts = _ps.executeBatch(); 940 941 for(int _countOffset = 0 ; _countOffset < _size ; _countOffset++) { 942 if(_counts[_countOffset] != 1 && _counts[_countOffset] != PreparedStatement.SUCCESS_NO_INFO) { 943 throw new PersistenceDatabaseUpdateException("batch insert failed, _counts[" + _countOffset + "] = " + _counts[_countOffset]); 944 } 945 } 946 } else { 947 _ps.executeBatch(); 948 } 949 950 _ps.clearBatch(); 951 } catch (SQLException se) { 952 throw new PersistenceDatabaseException(se); 953 } 954 955 _cacheValues.forEach((_cacheValue) -> { 956 DateTimeFormatDetail _cacheEntity = new DateTimeFormatDetail(_cacheValue, EntityPermission.READ_ONLY); 957 958 session.putReadOnlyEntity(_cacheValue.getPrimaryKey(), _cacheEntity); 959 }); 960 } 961 } 962 963 private boolean bindForStore(PreparedStatement _ps, DateTimeFormatDetailValue _value) 964 throws SQLException { 965 boolean _hasBeenModified = _value.hasBeenModified(); 966 967 if(_hasBeenModified) { 968 DateTimeFormatPK dtfdt_dtf_datetimeformatid = _value.getDateTimeFormatPK(); 969 if(dtfdt_dtf_datetimeformatid == null) 970 _ps.setNull(1, Types.BIGINT); 971 else 972 _ps.setLong(1, dtfdt_dtf_datetimeformatid.getEntityId()); 973 974 String dtfdt_datetimeformatname = _value.getDateTimeFormatName(); 975 if(dtfdt_datetimeformatname == null) 976 _ps.setNull(2, Types.VARCHAR); 977 else 978 _ps.setString(2, dtfdt_datetimeformatname); 979 980 String dtfdt_javashortdateformat = _value.getJavaShortDateFormat(); 981 if(dtfdt_javashortdateformat == null) 982 _ps.setNull(3, Types.VARCHAR); 983 else 984 _ps.setString(3, dtfdt_javashortdateformat); 985 986 String dtfdt_javaabbrevdateformat = _value.getJavaAbbrevDateFormat(); 987 if(dtfdt_javaabbrevdateformat == null) 988 _ps.setNull(4, Types.VARCHAR); 989 else 990 _ps.setString(4, dtfdt_javaabbrevdateformat); 991 992 String dtfdt_javaabbrevdateformatweekday = _value.getJavaAbbrevDateFormatWeekday(); 993 if(dtfdt_javaabbrevdateformatweekday == null) 994 _ps.setNull(5, Types.VARCHAR); 995 else 996 _ps.setString(5, dtfdt_javaabbrevdateformatweekday); 997 998 String dtfdt_javalongdateformat = _value.getJavaLongDateFormat(); 999 if(dtfdt_javalongdateformat == null) 1000 _ps.setNull(6, Types.VARCHAR); 1001 else 1002 _ps.setString(6, dtfdt_javalongdateformat); 1003 1004 String dtfdt_javalongdateformatweekday = _value.getJavaLongDateFormatWeekday(); 1005 if(dtfdt_javalongdateformatweekday == null) 1006 _ps.setNull(7, Types.VARCHAR); 1007 else 1008 _ps.setString(7, dtfdt_javalongdateformatweekday); 1009 1010 String dtfdt_javatimeformat = _value.getJavaTimeFormat(); 1011 if(dtfdt_javatimeformat == null) 1012 _ps.setNull(8, Types.VARCHAR); 1013 else 1014 _ps.setString(8, dtfdt_javatimeformat); 1015 1016 String dtfdt_javatimeformatseconds = _value.getJavaTimeFormatSeconds(); 1017 if(dtfdt_javatimeformatseconds == null) 1018 _ps.setNull(9, Types.VARCHAR); 1019 else 1020 _ps.setString(9, dtfdt_javatimeformatseconds); 1021 1022 String dtfdt_unixshortdateformat = _value.getUnixShortDateFormat(); 1023 if(dtfdt_unixshortdateformat == null) 1024 _ps.setNull(10, Types.VARCHAR); 1025 else 1026 _ps.setString(10, dtfdt_unixshortdateformat); 1027 1028 String dtfdt_unixabbrevdateformat = _value.getUnixAbbrevDateFormat(); 1029 if(dtfdt_unixabbrevdateformat == null) 1030 _ps.setNull(11, Types.VARCHAR); 1031 else 1032 _ps.setString(11, dtfdt_unixabbrevdateformat); 1033 1034 String dtfdt_unixabbrevdateformatweekday = _value.getUnixAbbrevDateFormatWeekday(); 1035 if(dtfdt_unixabbrevdateformatweekday == null) 1036 _ps.setNull(12, Types.VARCHAR); 1037 else 1038 _ps.setString(12, dtfdt_unixabbrevdateformatweekday); 1039 1040 String dtfdt_unixlongdateformat = _value.getUnixLongDateFormat(); 1041 if(dtfdt_unixlongdateformat == null) 1042 _ps.setNull(13, Types.VARCHAR); 1043 else 1044 _ps.setString(13, dtfdt_unixlongdateformat); 1045 1046 String dtfdt_unixlongdateformatweekday = _value.getUnixLongDateFormatWeekday(); 1047 if(dtfdt_unixlongdateformatweekday == null) 1048 _ps.setNull(14, Types.VARCHAR); 1049 else 1050 _ps.setString(14, dtfdt_unixlongdateformatweekday); 1051 1052 String dtfdt_unixtimeformat = _value.getUnixTimeFormat(); 1053 if(dtfdt_unixtimeformat == null) 1054 _ps.setNull(15, Types.VARCHAR); 1055 else 1056 _ps.setString(15, dtfdt_unixtimeformat); 1057 1058 String dtfdt_unixtimeformatseconds = _value.getUnixTimeFormatSeconds(); 1059 if(dtfdt_unixtimeformatseconds == null) 1060 _ps.setNull(16, Types.VARCHAR); 1061 else 1062 _ps.setString(16, dtfdt_unixtimeformatseconds); 1063 1064 String dtfdt_shortdateseparator = _value.getShortDateSeparator(); 1065 if(dtfdt_shortdateseparator == null) 1066 _ps.setNull(17, Types.VARCHAR); 1067 else 1068 _ps.setString(17, dtfdt_shortdateseparator); 1069 1070 String dtfdt_timeseparator = _value.getTimeSeparator(); 1071 if(dtfdt_timeseparator == null) 1072 _ps.setNull(18, Types.VARCHAR); 1073 else 1074 _ps.setString(18, dtfdt_timeseparator); 1075 1076 Boolean dtfdt_isdefault = _value.getIsDefault(); 1077 if(dtfdt_isdefault == null) 1078 _ps.setNull(19, Types.BIT); 1079 else 1080 _ps.setInt(19, dtfdt_isdefault? 1: 0); 1081 1082 Integer dtfdt_sortorder = _value.getSortOrder(); 1083 if(dtfdt_sortorder == null) 1084 _ps.setNull(20, Types.INTEGER); 1085 else 1086 _ps.setInt(20, dtfdt_sortorder); 1087 1088 Long dtfdt_fromtime = _value.getFromTime(); 1089 if(dtfdt_fromtime == null) 1090 _ps.setNull(21, Types.BIGINT); 1091 else 1092 _ps.setLong(21, dtfdt_fromtime); 1093 1094 Long dtfdt_thrutime = _value.getThruTime(); 1095 if(dtfdt_thrutime == null) 1096 _ps.setNull(22, Types.BIGINT); 1097 else 1098 _ps.setLong(22, dtfdt_thrutime); 1099 1100 _ps.setLong(23, _value.getPrimaryKey().getEntityId()); 1101 1102 _value.clearHasBeenModified(); 1103 } 1104 1105 return _hasBeenModified; 1106 } 1107 1108 @Override 1109 public void store(DateTimeFormatDetail entity) 1110 throws PersistenceDatabaseException { 1111 PreparedStatement _ps = session.prepareStatement(SQL_UPDATE); 1112 1113 try { 1114 DateTimeFormatDetailValue _value = entity.getDateTimeFormatDetailValue(); 1115 1116 if(bindForStore(_ps, _value)) { 1117 if(PersistenceDebugFlags.CheckEntityUpdateRowCount) { 1118 int _count = _ps.executeUpdate(); 1119 1120 if(_count != 1) { 1121 throw new PersistenceDatabaseUpdateException("update failed, _count = " + _count); 1122 } 1123 } else { 1124 _ps.executeUpdate(); 1125 } 1126 1127 session.getValueCache().put(_value); 1128 } 1129 } catch (SQLException se) { 1130 throw new PersistenceDatabaseException(se); 1131 } 1132 } 1133 1134 @Override 1135 public void store(Collection<DateTimeFormatDetail> entities) 1136 throws PersistenceDatabaseException { 1137 if(entities.size() > 0) { 1138 PreparedStatement _ps = session.prepareStatement(SQL_UPDATE); 1139 int _modifiedEntities = 0; 1140 1141 try { 1142 for(DateTimeFormatDetail entity : entities) { 1143 if(bindForStore(_ps, entity.getDateTimeFormatDetailValue())) { 1144 _ps.addBatch(); 1145 _modifiedEntities++; 1146 } 1147 } 1148 1149 if(_modifiedEntities != 0) { 1150 if(PersistenceDebugFlags.CheckEntityUpdateRowCount) { 1151 int[] _counts = _ps.executeBatch(); 1152 1153 for(int _countOffset = 0 ; _countOffset < _modifiedEntities ; _countOffset++) { 1154 if(_counts[_countOffset] != 1 && _counts[_countOffset] != PreparedStatement.SUCCESS_NO_INFO) { 1155 throw new PersistenceDatabaseUpdateException("batch update failed, _counts[" + _countOffset + "] = " + _counts[_countOffset]); 1156 } 1157 } 1158 } else { 1159 _ps.executeBatch(); 1160 } 1161 1162 _ps.clearBatch(); 1163 1164 entities.forEach((entity) -> { 1165 session.getValueCache().put(entity.getDateTimeFormatDetailValue()); 1166 }); 1167 } 1168 } catch (SQLException se) { 1169 throw new PersistenceDatabaseException(se); 1170 } 1171 } 1172 } 1173 1174 @Override 1175 public void remove(DateTimeFormatDetail entity) 1176 throws PersistenceDatabaseException { 1177 remove(entity.getPrimaryKey()); 1178 } 1179 1180 @Override 1181 public void remove(DateTimeFormatDetailPK pk) 1182 throws PersistenceDatabaseException { 1183 PreparedStatement _ps = session.prepareStatement(SQL_DELETE); 1184 long _entityId = pk.getEntityId(); 1185 1186 try { 1187 _ps.setLong(1, _entityId); 1188 1189 if(PersistenceDebugFlags.CheckEntityDeleteRowCount) { 1190 int _count = _ps.executeUpdate(); 1191 1192 if(_count != 1) { 1193 throw new PersistenceDatabaseUpdateException("remove failed, _count = " + _count); 1194 } 1195 } else { 1196 _ps.executeUpdate(); 1197 } 1198 1199 session.getValueCache().remove(pk); 1200 } catch (SQLException se) { 1201 throw new PersistenceDatabaseException(se); 1202 } 1203 1204 session.removed(pk, false); 1205 } 1206 1207 @Override 1208 public void remove(Collection<DateTimeFormatDetailPK> pks) 1209 throws PersistenceDatabaseException { 1210 if(pks.size() > 0) { 1211 PreparedStatement _ps = session.prepareStatement(SQL_DELETE); 1212 int _modifiedEntities = 0; 1213 1214 try { 1215 for(DateTimeFormatDetailPK pk : pks) { 1216 long _entityId = pk.getEntityId(); 1217 1218 _ps.setLong(1, _entityId); 1219 1220 _ps.addBatch(); 1221 _modifiedEntities++; 1222 } 1223 1224 if(_modifiedEntities != 0) { 1225 if(PersistenceDebugFlags.CheckEntityDeleteRowCount) { 1226 int[] _counts = _ps.executeBatch(); 1227 1228 for(int _countOffset = 0 ; _countOffset < _modifiedEntities ; _countOffset++) { 1229 if(_counts[_countOffset] != 1 && _counts[_countOffset] != PreparedStatement.SUCCESS_NO_INFO) { 1230 throw new PersistenceDatabaseUpdateException("batch remove failed, _counts[" + _countOffset + "] = " + _counts[_countOffset]); 1231 } 1232 } 1233 } else { 1234 _ps.executeBatch(); 1235 } 1236 1237 _ps.clearBatch(); 1238 1239 pks.forEach((pk) -> { 1240 session.getValueCache().remove(pk); 1241 }); 1242 } 1243 } catch (SQLException se) { 1244 throw new PersistenceDatabaseException(se); 1245 } 1246 1247 pks.forEach((pk) -> { 1248 session.removed(pk, true); 1249 }); 1250 } 1251 } 1252 1253 @Override 1254 public boolean validPK(DateTimeFormatDetailPK pk) 1255 throws PersistenceDatabaseException { 1256 boolean valid = false; 1257 PreparedStatement _ps = session.prepareStatement(SQL_VALID); 1258 ResultSet _rs = null; 1259 1260 try { 1261 _ps.setLong(1, pk.getEntityId()); 1262 1263 _rs = _ps.executeQuery(); 1264 if(_rs.next()) { 1265 long _count = _rs.getLong(1); 1266 if(_rs.wasNull()) 1267 _count = 0; 1268 1269 if(_count == 1) 1270 valid = true; 1271 } 1272 } catch (SQLException se) { 1273 throw new PersistenceDatabaseException(se); 1274 } finally { 1275 if(_rs != null) { 1276 try { 1277 _rs.close(); 1278 } catch (SQLException se) { 1279 // do nothing 1280 } 1281 } 1282 } 1283 1284 return valid; 1285 } 1286 1287}