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