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