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