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