001// --------------------------------------------------------------------------------
002// Copyright 2002-2025 Echo Three, LLC
003//
004// Licensed under the Apache License, Version 2.0 (the "License");
005// you may not use this file except in compliance with the License.
006// You may obtain a copy of the License at
007//
008//     http://www.apache.org/licenses/LICENSE-2.0
009//
010// Unless required by applicable law or agreed to in writing, software
011// distributed under the License is distributed on an "AS IS" BASIS,
012// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013// See the License for the specific language governing permissions and
014// limitations under the License.
015// --------------------------------------------------------------------------------
016// Generated File -- DO NOT EDIT BY HAND
017// --------------------------------------------------------------------------------
018
019/**
020 * PartyTrainingClassDetailFactory.java
021 */
022
023package com.echothree.model.data.training.server.factory;
024
025import com.echothree.model.data.training.common.pk.PartyTrainingClassPK;
026import com.echothree.model.data.party.common.pk.PartyPK;
027import com.echothree.model.data.training.common.pk.TrainingClassPK;
028
029import com.echothree.model.data.training.server.entity.PartyTrainingClass;
030import com.echothree.model.data.party.server.entity.Party;
031import com.echothree.model.data.training.server.entity.TrainingClass;
032
033import com.echothree.model.data.training.common.PartyTrainingClassDetailConstants;
034import com.echothree.model.data.training.common.pk.PartyTrainingClassDetailPK;
035import com.echothree.model.data.training.server.value.PartyTrainingClassDetailValue;
036import com.echothree.model.data.training.server.entity.PartyTrainingClassDetail;
037import com.echothree.util.common.exception.PersistenceDatabaseException;
038import com.echothree.util.common.exception.PersistenceDatabaseUpdateException;
039import com.echothree.util.common.exception.PersistenceNotNullException;
040import com.echothree.util.server.persistence.BaseFactory;
041import com.echothree.util.server.persistence.EntityIdGenerator;
042import com.echothree.util.server.persistence.EntityPermission;
043import com.echothree.util.server.persistence.PersistenceDebugFlags;
044import com.echothree.util.server.persistence.Session;
045import com.echothree.util.server.persistence.ThreadSession;
046import java.sql.PreparedStatement;
047import java.sql.ResultSet;
048import java.sql.SQLException;
049import java.sql.Types;
050import java.io.ByteArrayInputStream;
051import java.io.StringReader;
052import java.util.ArrayList;
053import java.util.Collection;
054import java.util.HashSet;
055import java.util.List;
056import java.util.Map;
057import java.util.Set;
058import javax.enterprise.context.ApplicationScoped;
059import javax.enterprise.inject.spi.CDI;
060import org.apache.commons.logging.Log;
061import org.apache.commons.logging.LogFactory;
062
063@ApplicationScoped
064public class PartyTrainingClassDetailFactory
065        implements BaseFactory<PartyTrainingClassDetailPK, PartyTrainingClassDetail> {
066    
067    //final private static Log log = LogFactory.getLog(PartyTrainingClassDetailFactory.class);
068    
069    final private static String SQL_SELECT_READ_ONLY = "SELECT ptrnclsdt_partytrainingclassdetailid, ptrnclsdt_ptrncls_partytrainingclassid, ptrnclsdt_partytrainingclassname, ptrnclsdt_par_partyid, ptrnclsdt_trncls_trainingclassid, ptrnclsdt_completedtime, ptrnclsdt_validuntiltime, ptrnclsdt_fromtime, ptrnclsdt_thrutime FROM partytrainingclassdetails WHERE ptrnclsdt_partytrainingclassdetailid = ?";
070    final private static String SQL_SELECT_READ_WRITE = "SELECT ptrnclsdt_partytrainingclassdetailid, ptrnclsdt_ptrncls_partytrainingclassid, ptrnclsdt_partytrainingclassname, ptrnclsdt_par_partyid, ptrnclsdt_trncls_trainingclassid, ptrnclsdt_completedtime, ptrnclsdt_validuntiltime, ptrnclsdt_fromtime, ptrnclsdt_thrutime FROM partytrainingclassdetails WHERE ptrnclsdt_partytrainingclassdetailid = ? FOR UPDATE";
071    final private static String SQL_INSERT = "INSERT INTO partytrainingclassdetails (ptrnclsdt_partytrainingclassdetailid, ptrnclsdt_ptrncls_partytrainingclassid, ptrnclsdt_partytrainingclassname, ptrnclsdt_par_partyid, ptrnclsdt_trncls_trainingclassid, ptrnclsdt_completedtime, ptrnclsdt_validuntiltime, ptrnclsdt_fromtime, ptrnclsdt_thrutime) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
072    final private static String SQL_UPDATE = "UPDATE partytrainingclassdetails SET ptrnclsdt_ptrncls_partytrainingclassid = ?, ptrnclsdt_partytrainingclassname = ?, ptrnclsdt_par_partyid = ?, ptrnclsdt_trncls_trainingclassid = ?, ptrnclsdt_completedtime = ?, ptrnclsdt_validuntiltime = ?, ptrnclsdt_fromtime = ?, ptrnclsdt_thrutime = ? WHERE ptrnclsdt_partytrainingclassdetailid = ?";
073    final private static String SQL_DELETE = "DELETE FROM partytrainingclassdetails WHERE ptrnclsdt_partytrainingclassdetailid = ?";
074    final private static String SQL_VALID = "SELECT COUNT(*) FROM partytrainingclassdetails WHERE ptrnclsdt_partytrainingclassdetailid = ?";
075    
076    final private static String PK_COLUMN = "ptrnclsdt_partytrainingclassdetailid";
077    final private static String ALL_COLUMNS = "ptrnclsdt_partytrainingclassdetailid, ptrnclsdt_ptrncls_partytrainingclassid, ptrnclsdt_partytrainingclassname, ptrnclsdt_par_partyid, ptrnclsdt_trncls_trainingclassid, ptrnclsdt_completedtime, ptrnclsdt_validuntiltime, ptrnclsdt_fromtime, ptrnclsdt_thrutime";
078    final public static String TABLE_NAME = "partytrainingclassdetails";
079    
080    final public static String PTRNCLSDT_PARTYTRAININGCLASSDETAILID = "ptrnclsdt_partytrainingclassdetailid";
081    final public static String PTRNCLSDT_PTRNCLS_PARTYTRAININGCLASSID = "ptrnclsdt_ptrncls_partytrainingclassid";
082    final public static String PTRNCLSDT_PARTYTRAININGCLASSNAME = "ptrnclsdt_partytrainingclassname";
083    final public static String PTRNCLSDT_PAR_PARTYID = "ptrnclsdt_par_partyid";
084    final public static String PTRNCLSDT_TRNCLS_TRAININGCLASSID = "ptrnclsdt_trncls_trainingclassid";
085    final public static String PTRNCLSDT_COMPLETEDTIME = "ptrnclsdt_completedtime";
086    final public static String PTRNCLSDT_VALIDUNTILTIME = "ptrnclsdt_validuntiltime";
087    final public static String PTRNCLSDT_FROMTIME = "ptrnclsdt_fromtime";
088    final public static String PTRNCLSDT_THRUTIME = "ptrnclsdt_thrutime";
089    
090    final private static EntityIdGenerator entityIdGenerator = new EntityIdGenerator(PartyTrainingClassDetailConstants.COMPONENT_VENDOR_NAME, PartyTrainingClassDetailConstants.ENTITY_TYPE_NAME);
091    
092    /** Creates a new instance of PartyTrainingClassDetailFactory */
093    protected PartyTrainingClassDetailFactory() {
094        super();
095    }
096    
097    public static PartyTrainingClassDetailFactory getInstance() {
098        return CDI.current().select(PartyTrainingClassDetailFactory.class).get();
099    }
100    
101    @Override
102    public String getPKColumn() {
103        return PK_COLUMN;
104    }
105    
106    @Override
107    public String getAllColumns() {
108        return ALL_COLUMNS;
109    }
110    
111    @Override
112    public String getTableName() {
113        return TABLE_NAME;
114    }
115    
116    @Override
117    public String getComponentVendorName() {
118        return PartyTrainingClassDetailConstants.COMPONENT_VENDOR_NAME;
119    }
120    
121    @Override
122    public String getEntityTypeName() {
123        return PartyTrainingClassDetailConstants.ENTITY_TYPE_NAME;
124    }
125    
126    public PreparedStatement prepareStatement(String query) {
127        return ThreadSession.currentSession().prepareStatement(PartyTrainingClassDetailFactory.class, query);
128    }
129    
130    public PartyTrainingClassDetailPK getNextPK() {
131        return new PartyTrainingClassDetailPK(entityIdGenerator.getNextEntityId());
132    }
133    
134    public Set<PartyTrainingClassDetailPK> getPKsFromResultSetAsSet(ResultSet rs)
135            throws PersistenceDatabaseException {
136        Set<PartyTrainingClassDetailPK> _result = new HashSet<>();
137        
138        try {
139            while(rs.next()) {
140                _result.add(getPKFromResultSet(rs));
141            }
142        } catch (SQLException se) {
143            throw new PersistenceDatabaseException(se);
144        }
145        
146        return _result;
147    }
148    
149    public java.util.List<PartyTrainingClassDetailPK> getPKsFromResultSetAsList(ResultSet rs)
150            throws PersistenceDatabaseException {
151        java.util.List<PartyTrainingClassDetailPK> _result = new ArrayList<>();
152        
153        try {
154            while(rs.next()) {
155                _result.add(getPKFromResultSet(rs));
156            }
157        } catch (SQLException se) {
158            throw new PersistenceDatabaseException(se);
159        }
160        
161        return _result;
162    }
163    
164    public PartyTrainingClassDetailPK getPKFromResultSet(ResultSet rs)
165            throws PersistenceDatabaseException {
166        PartyTrainingClassDetailPK _result;
167        
168        try {
169            long ptrnclsdt_partytrainingclassdetailid = rs.getLong(PTRNCLSDT_PARTYTRAININGCLASSDETAILID);
170            Long _entityId = rs.wasNull() ? null : ptrnclsdt_partytrainingclassdetailid;
171            
172            _result = new PartyTrainingClassDetailPK(_entityId);
173        } catch (SQLException se) {
174            throw new PersistenceDatabaseException(se);
175        }
176        
177        return _result;
178    }
179    
180    public java.util.List<PartyTrainingClassDetailValue> getValuesFromPKs(Session session, Collection<PartyTrainingClassDetailPK> pks)
181            throws PersistenceDatabaseException {
182        java.util.List<PartyTrainingClassDetailValue> _values = new ArrayList<>(pks.size());
183        
184        for(PartyTrainingClassDetailPK _pk: pks) {
185            _values.add(getValueFromPK(session, _pk));
186        }
187        
188        return _values;
189    }
190    
191    public PartyTrainingClassDetailValue getValueFromPK(Session session, PartyTrainingClassDetailPK pk)
192            throws PersistenceDatabaseException {
193        PartyTrainingClassDetailValue _value;
194        
195        // See if we already have the entity in the session cache
196        PartyTrainingClassDetail _entity = (PartyTrainingClassDetail)session.getEntity(pk);
197        if(_entity == null)
198            _value = getEntityFromPK(session, EntityPermission.READ_ONLY, pk).getPartyTrainingClassDetailValue();
199        else
200            _value = _entity.getPartyTrainingClassDetailValue();
201        
202        return _value;
203    }
204    
205    public java.util.List<PartyTrainingClassDetailValue> getValuesFromResultSet(Session session, ResultSet rs)
206            throws PersistenceDatabaseException {
207        java.util.List<PartyTrainingClassDetailValue> _result = new ArrayList<>();
208        
209        try {
210            while(rs.next()) {
211                _result.add(getValueFromResultSet(session, rs));
212            }
213        } catch (SQLException se) {
214            throw new PersistenceDatabaseException(se);
215        }
216        
217        return _result;
218    }
219    
220    public PartyTrainingClassDetailValue getValueFromResultSet(Session session, ResultSet rs)
221            throws PersistenceDatabaseException {
222        PartyTrainingClassDetailValue _value;
223        
224        try {
225            Long ptrnclsdt_partytrainingclassdetailid = rs.getLong(PTRNCLSDT_PARTYTRAININGCLASSDETAILID);
226            PartyTrainingClassDetailPK _pk = new PartyTrainingClassDetailPK(ptrnclsdt_partytrainingclassdetailid);
227            
228            // See if we already have the entity in the session cache
229            PartyTrainingClassDetail _entity = (PartyTrainingClassDetail)session.getEntity(_pk);
230            
231            if(_entity == null) {
232                Long ptrnclsdt_ptrncls_partytrainingclassid = rs.getLong(PTRNCLSDT_PTRNCLS_PARTYTRAININGCLASSID);
233                if(rs.wasNull())
234                    ptrnclsdt_ptrncls_partytrainingclassid = null;
235                
236                String ptrnclsdt_partytrainingclassname = rs.getString(PTRNCLSDT_PARTYTRAININGCLASSNAME);
237                if(rs.wasNull())
238                    ptrnclsdt_partytrainingclassname = null;
239                
240                Long ptrnclsdt_par_partyid = rs.getLong(PTRNCLSDT_PAR_PARTYID);
241                if(rs.wasNull())
242                    ptrnclsdt_par_partyid = null;
243                
244                Long ptrnclsdt_trncls_trainingclassid = rs.getLong(PTRNCLSDT_TRNCLS_TRAININGCLASSID);
245                if(rs.wasNull())
246                    ptrnclsdt_trncls_trainingclassid = null;
247                
248                Long ptrnclsdt_completedtime = rs.getLong(PTRNCLSDT_COMPLETEDTIME);
249                if(rs.wasNull())
250                    ptrnclsdt_completedtime = null;
251                
252                Long ptrnclsdt_validuntiltime = rs.getLong(PTRNCLSDT_VALIDUNTILTIME);
253                if(rs.wasNull())
254                    ptrnclsdt_validuntiltime = null;
255                
256                Long ptrnclsdt_fromtime = rs.getLong(PTRNCLSDT_FROMTIME);
257                if(rs.wasNull())
258                    ptrnclsdt_fromtime = null;
259                
260                Long ptrnclsdt_thrutime = rs.getLong(PTRNCLSDT_THRUTIME);
261                if(rs.wasNull())
262                    ptrnclsdt_thrutime = null;
263                
264                _value = new PartyTrainingClassDetailValue(_pk, new PartyTrainingClassPK(ptrnclsdt_ptrncls_partytrainingclassid), ptrnclsdt_partytrainingclassname, new PartyPK(ptrnclsdt_par_partyid), new TrainingClassPK(ptrnclsdt_trncls_trainingclassid), ptrnclsdt_completedtime, ptrnclsdt_validuntiltime, ptrnclsdt_fromtime, ptrnclsdt_thrutime);
265            } else
266                _value = _entity.getPartyTrainingClassDetailValue();
267        } catch (SQLException se) {
268            throw new PersistenceDatabaseException(se);
269        }
270        
271        return _value;
272    }
273    
274    public java.util.List<PartyTrainingClassDetail> getEntitiesFromPKs(EntityPermission entityPermission, Collection<PartyTrainingClassDetailPK> pks)
275            throws PersistenceDatabaseException {
276        return getEntitiesFromPKs(ThreadSession.currentSession(), entityPermission, pks);
277    }
278    
279    public java.util.List<PartyTrainingClassDetail> getEntitiesFromPKs(Session session, EntityPermission entityPermission, Collection<PartyTrainingClassDetailPK> pks)
280            throws PersistenceDatabaseException {
281        java.util.List<PartyTrainingClassDetail> _entities = new ArrayList<>(pks.size());
282        
283        for(PartyTrainingClassDetailPK _pk: pks) {
284            _entities.add(getEntityFromPK(session, entityPermission, _pk));
285        }
286        
287        return _entities;
288    }
289    
290    public PartyTrainingClassDetail getEntityFromValue(EntityPermission entityPermission, PartyTrainingClassDetailValue value) {
291        return getEntityFromPK(ThreadSession.currentSession(), entityPermission, value.getPrimaryKey());
292    }
293    
294    public PartyTrainingClassDetail getEntityFromValue(Session session, EntityPermission entityPermission, PartyTrainingClassDetailValue value) {
295        return getEntityFromPK(session, entityPermission, value.getPrimaryKey());
296    }
297    
298    public PartyTrainingClassDetail getEntityFromPK(EntityPermission entityPermission, PartyTrainingClassDetailPK pk)
299            throws PersistenceDatabaseException {
300        return getEntityFromPK(ThreadSession.currentSession(), entityPermission, pk);
301    }
302    
303    public PartyTrainingClassDetail getEntityFromCache(Session session, PartyTrainingClassDetailPK pk) {
304        PartyTrainingClassDetailValue _value = (PartyTrainingClassDetailValue)session.getValueCache().get(pk);
305    
306        return _value == null ? null : new PartyTrainingClassDetail(_value, EntityPermission.READ_ONLY);
307    }
308    
309    public PartyTrainingClassDetail getEntityFromPK(Session session, EntityPermission entityPermission, PartyTrainingClassDetailPK pk)
310            throws PersistenceDatabaseException {
311        PartyTrainingClassDetail _entity;
312        
313        // See if we already have the entity in the session cache
314        _entity = (PartyTrainingClassDetail)session.getEntity(pk);
315        if(_entity != null) {
316            // If the requested permission is READ_WRITE, and the cached permission is
317            // READ_ONLY, then pretend that the cached object wasn't found, and create
318            // a new entity that is READ_WRITE.
319            if(entityPermission.equals(EntityPermission.READ_WRITE)) {
320                if(_entity.getEntityPermission().equals(EntityPermission.READ_ONLY))
321                    _entity = null;
322            }
323        }
324        
325        if(_entity == null && entityPermission.equals(EntityPermission.READ_ONLY)) {
326            _entity = getEntityFromCache(session, pk);
327        }
328        
329        if(_entity == null) {
330            PreparedStatement _ps = session.prepareStatement(entityPermission.equals(EntityPermission.READ_ONLY)? SQL_SELECT_READ_ONLY: SQL_SELECT_READ_WRITE);
331            long _entityId = pk.getEntityId();
332            ResultSet _rs = null;
333            
334            try {
335                _ps.setLong(1, _entityId);
336                _rs = _ps.executeQuery();
337                if(_rs.next()) {
338                    _entity = getEntityFromResultSet(session, entityPermission, _rs);
339                }
340            } catch (SQLException se) {
341                throw new PersistenceDatabaseException(se);
342            } finally {
343                if(_rs != null) {
344                    try {
345                        _rs.close();
346                    } catch (SQLException se) {
347                        // do nothing
348                    }
349                }
350            }
351        }
352        
353        return _entity;
354    }
355    
356    public Set<PartyTrainingClassDetailPK> getPKsFromQueryAsSet(PreparedStatement ps, final Object... params)
357            throws PersistenceDatabaseException {
358        Set<PartyTrainingClassDetailPK> _pks;
359        ResultSet _rs = null;
360        
361        try {
362            if(params.length != 0) {
363                Session.setQueryParams(ps, params);
364            }
365            
366            _rs = ps.executeQuery();
367            _pks = getPKsFromResultSetAsSet(_rs);
368            _rs.close();
369        } catch (SQLException se) {
370            throw new PersistenceDatabaseException(se);
371        } finally {
372            if(_rs != null) {
373                try {
374                    _rs.close();
375                } catch (SQLException se) {
376                    // do nothing
377                }
378            }
379        }
380        
381        return _pks;
382    }
383    
384    public java.util.List<PartyTrainingClassDetailPK> getPKsFromQueryAsList(PreparedStatement ps, final Object... params)
385            throws PersistenceDatabaseException {
386        java.util.List<PartyTrainingClassDetailPK> _pks;
387        ResultSet _rs = null;
388        
389        try {
390            if(params.length != 0) {
391                Session.setQueryParams(ps, params);
392            }
393            
394            _rs = ps.executeQuery();
395            _pks = getPKsFromResultSetAsList(_rs);
396            _rs.close();
397        } catch (SQLException se) {
398            throw new PersistenceDatabaseException(se);
399        } finally {
400            if(_rs != null) {
401                try {
402                    _rs.close();
403                } catch (SQLException se) {
404                    // do nothing
405                }
406            }
407        }
408        
409        return _pks;
410    }
411    
412    public PartyTrainingClassDetailPK getPKFromQuery(PreparedStatement ps, final Object... params)
413            throws PersistenceDatabaseException {
414        PartyTrainingClassDetailPK _pk = null;
415        ResultSet _rs = null;
416        
417        try {
418            if(params.length != 0) {
419                Session.setQueryParams(ps, params);
420            }
421            
422            _rs = ps.executeQuery();
423            if(_rs.next()) {
424                _pk = getPKFromResultSet(_rs);
425            }
426            _rs.close();
427        } catch (SQLException se) {
428            throw new PersistenceDatabaseException(se);
429        } finally {
430            if(_rs != null) {
431                try {
432                    _rs.close();
433                } catch (SQLException se) {
434                    // do nothing
435                }
436            }
437        }
438        
439        return _pk;
440    }
441    
442    public java.util.List<PartyTrainingClassDetail> getEntitiesFromQuery(Session session, EntityPermission entityPermission, Map<EntityPermission, String>queryMap, final Object... params)
443            throws PersistenceDatabaseException {
444        PreparedStatement ps = session.prepareStatement(PartyTrainingClassDetailFactory.class, queryMap.get(entityPermission));
445        
446        return getEntitiesFromQuery(session, entityPermission, ps, params);
447    }
448    
449    public java.util.List<PartyTrainingClassDetail> getEntitiesFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap, final Object... params)
450            throws PersistenceDatabaseException {
451        Session session = ThreadSession.currentSession();
452        PreparedStatement ps = session.prepareStatement(PartyTrainingClassDetailFactory.class, queryMap.get(entityPermission));
453        
454        return getEntitiesFromQuery(session, entityPermission, ps, params);
455    }
456    
457    public java.util.List<PartyTrainingClassDetail> getEntitiesFromQuery(Session session, EntityPermission entityPermission, Map<EntityPermission, String>queryMap)
458            throws PersistenceDatabaseException {
459        PreparedStatement ps = session.prepareStatement(PartyTrainingClassDetailFactory.class, queryMap.get(entityPermission));
460        
461        return getEntitiesFromQuery(session, entityPermission, ps);
462    }
463    
464    public java.util.List<PartyTrainingClassDetail> getEntitiesFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap)
465            throws PersistenceDatabaseException {
466        Session session = ThreadSession.currentSession();
467        PreparedStatement ps = session.prepareStatement(PartyTrainingClassDetailFactory.class, queryMap.get(entityPermission));
468        
469        return getEntitiesFromQuery(session, entityPermission, ps);
470    }
471    
472    public java.util.List<PartyTrainingClassDetail> getEntitiesFromQuery(EntityPermission entityPermission, PreparedStatement ps)
473            throws PersistenceDatabaseException {
474        return getEntitiesFromQuery(ThreadSession.currentSession(), entityPermission, ps);
475    }
476    
477    public java.util.List<PartyTrainingClassDetail> getEntitiesFromQuery(EntityPermission entityPermission, PreparedStatement ps, final Object... params)
478            throws PersistenceDatabaseException {
479        return getEntitiesFromQuery(ThreadSession.currentSession(), entityPermission, ps, params);
480    }
481    
482    public java.util.List<PartyTrainingClassDetail> getEntitiesFromQuery(Session session, EntityPermission entityPermission, PreparedStatement ps, final Object... params)
483            throws PersistenceDatabaseException {
484        java.util.List<PartyTrainingClassDetail> _entities;
485        ResultSet _rs = null;
486        
487        try {
488            if(params.length != 0) {
489                Session.setQueryParams(ps, params);
490            }
491            
492            _rs = ps.executeQuery();
493            _entities = getEntitiesFromResultSet(session, entityPermission, _rs);
494            _rs.close();
495        } catch (SQLException se) {
496            throw new PersistenceDatabaseException(se);
497        } finally {
498            if(_rs != null) {
499                try {
500                    _rs.close();
501                } catch (SQLException se) {
502                    // do nothing
503                }
504            }
505        }
506        
507        return _entities;
508    }
509    
510    public PartyTrainingClassDetail getEntityFromQuery(Session session, EntityPermission entityPermission, Map<EntityPermission, String>queryMap, final Object... params)
511            throws PersistenceDatabaseException {
512        PreparedStatement ps = session.prepareStatement(PartyTrainingClassDetailFactory.class, queryMap.get(entityPermission));
513        
514        return getEntityFromQuery(session, entityPermission, ps, params);
515    }
516    
517    public PartyTrainingClassDetail getEntityFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap, final Object... params)
518            throws PersistenceDatabaseException {
519        Session session = ThreadSession.currentSession();
520        PreparedStatement ps = session.prepareStatement(PartyTrainingClassDetailFactory.class, queryMap.get(entityPermission));
521        
522        return getEntityFromQuery(session, entityPermission, ps, params);
523    }
524    
525    public PartyTrainingClassDetail getEntityFromQuery(Session session, EntityPermission entityPermission, Map<EntityPermission, String>queryMap)
526            throws PersistenceDatabaseException {
527        PreparedStatement ps = session.prepareStatement(PartyTrainingClassDetailFactory.class, queryMap.get(entityPermission));
528        
529        return getEntityFromQuery(session, entityPermission, ps);
530    }
531    
532    public PartyTrainingClassDetail getEntityFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap)
533            throws PersistenceDatabaseException {
534        Session session = ThreadSession.currentSession();
535        PreparedStatement ps = session.prepareStatement(PartyTrainingClassDetailFactory.class, queryMap.get(entityPermission));
536        
537        return getEntityFromQuery(session, entityPermission, ps);
538    }
539    
540    public PartyTrainingClassDetail getEntityFromQuery(EntityPermission entityPermission, PreparedStatement ps)
541            throws PersistenceDatabaseException {
542        return getEntityFromQuery(ThreadSession.currentSession(), entityPermission, ps);
543    }
544    
545    public PartyTrainingClassDetail getEntityFromQuery(EntityPermission entityPermission, PreparedStatement ps, final Object... params)
546            throws PersistenceDatabaseException {
547        return getEntityFromQuery(ThreadSession.currentSession(), entityPermission, ps, params);
548    }
549    
550    public PartyTrainingClassDetail getEntityFromQuery(Session session, EntityPermission entityPermission, PreparedStatement ps, final Object... params)
551            throws PersistenceDatabaseException {
552        PartyTrainingClassDetail _entity = null;
553        ResultSet _rs = null;
554        
555        try {
556            if(params.length != 0) {
557                Session.setQueryParams(ps, params);
558            }
559            
560            _rs = ps.executeQuery();
561            if(_rs.next()) {
562                _entity = getEntityFromResultSet(session, entityPermission, _rs);
563            }
564            _rs.close();
565        } catch (SQLException se) {
566            throw new PersistenceDatabaseException(se);
567        } finally {
568            if(_rs != null) {
569                try {
570                    _rs.close();
571                } catch (SQLException se) {
572                    // do nothing
573                }
574            }
575        }
576        
577        return _entity;
578    }
579    
580    public java.util.List<PartyTrainingClassDetail> getEntitiesFromResultSet(EntityPermission entityPermission, ResultSet rs)
581            throws PersistenceDatabaseException {
582        return getEntitiesFromResultSet(ThreadSession.currentSession(), entityPermission, rs);
583    }
584    
585    public java.util.List<PartyTrainingClassDetail> getEntitiesFromResultSet(Session session, EntityPermission entityPermission, ResultSet rs)
586            throws PersistenceDatabaseException {
587        java.util.List<PartyTrainingClassDetail> _result = new ArrayList<>();
588        
589        try {
590            while(rs.next()) {
591                _result.add(getEntityFromResultSet(session, entityPermission, rs));
592            }
593        } catch (SQLException se) {
594            throw new PersistenceDatabaseException(se);
595        }
596        
597        return _result;
598    }
599    
600    public PartyTrainingClassDetail getEntityFromResultSet(EntityPermission entityPermission, ResultSet rs)
601            throws PersistenceDatabaseException {
602        return getEntityFromResultSet(ThreadSession.currentSession(), entityPermission, rs);
603    }
604    
605    public PartyTrainingClassDetail getEntityFromResultSet(Session session, EntityPermission entityPermission, ResultSet rs)
606            throws PersistenceDatabaseException {
607        PartyTrainingClassDetail _entity;
608        
609        try {
610            Long ptrnclsdt_partytrainingclassdetailid = rs.getLong(PTRNCLSDT_PARTYTRAININGCLASSDETAILID);
611            PartyTrainingClassDetailPK _pk = new PartyTrainingClassDetailPK(ptrnclsdt_partytrainingclassdetailid);
612            
613            // See if we already have the entity in the session cache
614            _entity = (PartyTrainingClassDetail)session.getEntity(_pk);
615            if(_entity != null) {
616                // If the requested permission is READ_WRITE, and the cached permission is
617                // READ_ONLY, then pretend that the cached object wasn't found, and create
618                // a new entity that is READ_WRITE.
619                if(entityPermission.equals(EntityPermission.READ_WRITE)) {
620                    if(_entity.getEntityPermission().equals(EntityPermission.READ_ONLY))
621                        _entity = null;
622                }
623            }
624            boolean foundInSessionCache = _entity != null;
625            
626            if(_entity == null && entityPermission.equals(EntityPermission.READ_ONLY)) {
627                _entity = getEntityFromCache(session, _pk);
628            }
629            
630            if(_entity == null) {
631                Long ptrnclsdt_ptrncls_partytrainingclassid = rs.getLong(PTRNCLSDT_PTRNCLS_PARTYTRAININGCLASSID);
632                if(rs.wasNull())
633                    ptrnclsdt_ptrncls_partytrainingclassid = null;
634                
635                String ptrnclsdt_partytrainingclassname = rs.getString(PTRNCLSDT_PARTYTRAININGCLASSNAME);
636                if(rs.wasNull())
637                    ptrnclsdt_partytrainingclassname = null;
638                
639                Long ptrnclsdt_par_partyid = rs.getLong(PTRNCLSDT_PAR_PARTYID);
640                if(rs.wasNull())
641                    ptrnclsdt_par_partyid = null;
642                
643                Long ptrnclsdt_trncls_trainingclassid = rs.getLong(PTRNCLSDT_TRNCLS_TRAININGCLASSID);
644                if(rs.wasNull())
645                    ptrnclsdt_trncls_trainingclassid = null;
646                
647                Long ptrnclsdt_completedtime = rs.getLong(PTRNCLSDT_COMPLETEDTIME);
648                if(rs.wasNull())
649                    ptrnclsdt_completedtime = null;
650                
651                Long ptrnclsdt_validuntiltime = rs.getLong(PTRNCLSDT_VALIDUNTILTIME);
652                if(rs.wasNull())
653                    ptrnclsdt_validuntiltime = null;
654                
655                Long ptrnclsdt_fromtime = rs.getLong(PTRNCLSDT_FROMTIME);
656                if(rs.wasNull())
657                    ptrnclsdt_fromtime = null;
658                
659                Long ptrnclsdt_thrutime = rs.getLong(PTRNCLSDT_THRUTIME);
660                if(rs.wasNull())
661                    ptrnclsdt_thrutime = null;
662                
663                PartyTrainingClassDetailValue _value = new PartyTrainingClassDetailValue(_pk, ptrnclsdt_ptrncls_partytrainingclassid == null? null: new PartyTrainingClassPK(ptrnclsdt_ptrncls_partytrainingclassid), ptrnclsdt_partytrainingclassname, ptrnclsdt_par_partyid == null? null: new PartyPK(ptrnclsdt_par_partyid), ptrnclsdt_trncls_trainingclassid == null? null: new TrainingClassPK(ptrnclsdt_trncls_trainingclassid), ptrnclsdt_completedtime, ptrnclsdt_validuntiltime, ptrnclsdt_fromtime, ptrnclsdt_thrutime);
664                _entity = new PartyTrainingClassDetail(_value, entityPermission);
665            }
666            
667            if(!foundInSessionCache) {
668                if(entityPermission.equals(EntityPermission.READ_ONLY)) {
669                    session.putReadOnlyEntity(_pk, _entity);
670                    session.getValueCache().put(_entity.getPartyTrainingClassDetailValue());
671                } else {
672                    session.putReadWriteEntity(_pk, _entity);
673                }
674            }
675        } catch (SQLException se) {
676            throw new PersistenceDatabaseException(se);
677        }
678        
679        return _entity;
680    }
681    
682    public PartyTrainingClassDetail create(Session session, PartyTrainingClass partyTrainingClass, String partyTrainingClassName, Party party, TrainingClass trainingClass, Long completedTime, Long validUntilTime, Long fromTime, Long thruTime)
683            throws PersistenceDatabaseException, PersistenceNotNullException {
684        return create(session, partyTrainingClass == null ? null : partyTrainingClass.getPrimaryKey(), partyTrainingClassName, party == null ? null : party.getPrimaryKey(), trainingClass == null ? null : trainingClass.getPrimaryKey(), completedTime, validUntilTime, fromTime, thruTime);
685    }
686    
687    public PartyTrainingClassDetail create(PartyTrainingClass partyTrainingClass, String partyTrainingClassName, Party party, TrainingClass trainingClass, Long completedTime, Long validUntilTime, Long fromTime, Long thruTime)
688            throws PersistenceDatabaseException, PersistenceNotNullException {
689        return create(ThreadSession.currentSession(), partyTrainingClass == null ? null : partyTrainingClass.getPrimaryKey(), partyTrainingClassName, party == null ? null : party.getPrimaryKey(), trainingClass == null ? null : trainingClass.getPrimaryKey(), completedTime, validUntilTime, fromTime, thruTime);
690    }
691    
692    private void bindForCreate(PreparedStatement _ps, PartyTrainingClassDetailValue _value)
693            throws SQLException {
694        _ps.setLong(1, _value.getEntityId());
695        
696        PartyTrainingClassPK ptrnclsdt_ptrncls_partytrainingclassid = _value.getPartyTrainingClassPK();
697        if(ptrnclsdt_ptrncls_partytrainingclassid == null)
698            _ps.setNull(2, Types.BIGINT);
699        else
700            _ps.setLong(2, ptrnclsdt_ptrncls_partytrainingclassid.getEntityId());
701            
702        String ptrnclsdt_partytrainingclassname = _value.getPartyTrainingClassName();
703        if(ptrnclsdt_partytrainingclassname == null)
704            _ps.setNull(3, Types.VARCHAR);
705        else
706            _ps.setString(3, ptrnclsdt_partytrainingclassname);
707            
708        PartyPK ptrnclsdt_par_partyid = _value.getPartyPK();
709        if(ptrnclsdt_par_partyid == null)
710            _ps.setNull(4, Types.BIGINT);
711        else
712            _ps.setLong(4, ptrnclsdt_par_partyid.getEntityId());
713            
714        TrainingClassPK ptrnclsdt_trncls_trainingclassid = _value.getTrainingClassPK();
715        if(ptrnclsdt_trncls_trainingclassid == null)
716            _ps.setNull(5, Types.BIGINT);
717        else
718            _ps.setLong(5, ptrnclsdt_trncls_trainingclassid.getEntityId());
719            
720        Long ptrnclsdt_completedtime = _value.getCompletedTime();
721        if(ptrnclsdt_completedtime == null)
722            _ps.setNull(6, Types.BIGINT);
723        else
724            _ps.setLong(6, ptrnclsdt_completedtime);
725            
726        Long ptrnclsdt_validuntiltime = _value.getValidUntilTime();
727        if(ptrnclsdt_validuntiltime == null)
728            _ps.setNull(7, Types.BIGINT);
729        else
730            _ps.setLong(7, ptrnclsdt_validuntiltime);
731            
732        Long ptrnclsdt_fromtime = _value.getFromTime();
733        if(ptrnclsdt_fromtime == null)
734            _ps.setNull(8, Types.BIGINT);
735        else
736            _ps.setLong(8, ptrnclsdt_fromtime);
737            
738        Long ptrnclsdt_thrutime = _value.getThruTime();
739        if(ptrnclsdt_thrutime == null)
740            _ps.setNull(9, Types.BIGINT);
741        else
742            _ps.setLong(9, ptrnclsdt_thrutime);
743            
744    }
745    
746    public PartyTrainingClassDetail create(Session session, PartyTrainingClassPK partyTrainingClassPK, String partyTrainingClassName, PartyPK partyPK, TrainingClassPK trainingClassPK, Long completedTime, Long validUntilTime, Long fromTime, Long thruTime)
747            throws PersistenceDatabaseException, PersistenceNotNullException {
748        PartyTrainingClassDetailPK _pk = getNextPK();
749        PartyTrainingClassDetailValue _value = new PartyTrainingClassDetailValue(_pk, partyTrainingClassPK, partyTrainingClassName, partyPK, trainingClassPK, completedTime, validUntilTime, fromTime, thruTime);
750        
751        PreparedStatement _ps = session.prepareStatement(SQL_INSERT);
752        
753        try {
754            bindForCreate(_ps, _value);
755            
756            if(PersistenceDebugFlags.CheckEntityInsertRowCount) {
757                int _count = _ps.executeUpdate();
758                
759                if(_count != 1) {
760                    throw new PersistenceDatabaseUpdateException("insert failed, _count = " + _count);
761                }
762            } else {
763                 _ps.executeUpdate();
764            }
765            
766            session.getValueCache().put(_value);
767        } catch (SQLException se) {
768            throw new PersistenceDatabaseException(se);
769        }
770        
771        PartyTrainingClassDetail _entity = new PartyTrainingClassDetail(_value, EntityPermission.READ_ONLY);
772        session.putReadOnlyEntity(_pk, _entity);
773        
774        return _entity;
775    }
776    
777    public PartyTrainingClassDetail create(PartyTrainingClassPK partyTrainingClassPK, String partyTrainingClassName, PartyPK partyPK, TrainingClassPK trainingClassPK, Long completedTime, Long validUntilTime, Long fromTime, Long thruTime)
778            throws PersistenceDatabaseException, PersistenceNotNullException {
779        return create(ThreadSession.currentSession(), partyTrainingClassPK, partyTrainingClassName, partyPK, trainingClassPK, completedTime, validUntilTime, fromTime, thruTime);
780    }
781    
782    public void create(Session session, Collection<PartyTrainingClassDetailValue> _values)
783            throws PersistenceDatabaseException, PersistenceNotNullException {
784        int _size = _values.size();
785        
786        if(_size > 0) {
787            PreparedStatement _ps = session.prepareStatement(SQL_INSERT);
788            List<PartyTrainingClassDetailValue> _cacheValues = new ArrayList<>(_size);
789            
790            try {
791                for(PartyTrainingClassDetailValue _value : _values) {
792                    _value.setEntityId(entityIdGenerator.getNextEntityId());
793                    bindForCreate(_ps, _value);
794                    
795                    _ps.addBatch();
796                    
797                    _cacheValues.add(_value);
798                }
799                
800                if(PersistenceDebugFlags.CheckEntityInsertRowCount) {
801                    int[] _counts = _ps.executeBatch();
802                    
803                    for(int _countOffset = 0 ; _countOffset < _size ; _countOffset++) {
804                        if(_counts[_countOffset] != 1 && _counts[_countOffset] != PreparedStatement.SUCCESS_NO_INFO) {
805                            throw new PersistenceDatabaseUpdateException("batch insert failed, _counts[" + _countOffset + "] = " + _counts[_countOffset]);
806                        }
807                    }
808                } else {
809                     _ps.executeBatch();
810                }
811                
812                _ps.clearBatch();
813            } catch (SQLException se) {
814                throw new PersistenceDatabaseException(se);
815            }
816            
817            _cacheValues.forEach((_cacheValue) -> {
818                PartyTrainingClassDetail _cacheEntity = new PartyTrainingClassDetail(_cacheValue, EntityPermission.READ_ONLY);
819                
820                session.putReadOnlyEntity(_cacheValue.getPrimaryKey(), _cacheEntity);
821            });
822        }
823    }
824    
825    public void create(Collection<PartyTrainingClassDetailValue> _values)
826            throws PersistenceDatabaseException, PersistenceNotNullException {
827        create(ThreadSession.currentSession(), _values);
828    }
829    
830    private boolean bindForStore(PreparedStatement _ps, PartyTrainingClassDetailValue _value)
831            throws SQLException {
832        boolean _hasBeenModified = _value.hasBeenModified();
833        
834        if(_hasBeenModified) {
835            PartyTrainingClassPK ptrnclsdt_ptrncls_partytrainingclassid = _value.getPartyTrainingClassPK();
836            if(ptrnclsdt_ptrncls_partytrainingclassid == null)
837                _ps.setNull(1, Types.BIGINT);
838            else
839                _ps.setLong(1, ptrnclsdt_ptrncls_partytrainingclassid.getEntityId());
840            
841            String ptrnclsdt_partytrainingclassname = _value.getPartyTrainingClassName();
842            if(ptrnclsdt_partytrainingclassname == null)
843                _ps.setNull(2, Types.VARCHAR);
844            else
845                _ps.setString(2, ptrnclsdt_partytrainingclassname);
846            
847            PartyPK ptrnclsdt_par_partyid = _value.getPartyPK();
848            if(ptrnclsdt_par_partyid == null)
849                _ps.setNull(3, Types.BIGINT);
850            else
851                _ps.setLong(3, ptrnclsdt_par_partyid.getEntityId());
852            
853            TrainingClassPK ptrnclsdt_trncls_trainingclassid = _value.getTrainingClassPK();
854            if(ptrnclsdt_trncls_trainingclassid == null)
855                _ps.setNull(4, Types.BIGINT);
856            else
857                _ps.setLong(4, ptrnclsdt_trncls_trainingclassid.getEntityId());
858            
859            Long ptrnclsdt_completedtime = _value.getCompletedTime();
860            if(ptrnclsdt_completedtime == null)
861                _ps.setNull(5, Types.BIGINT);
862            else
863                _ps.setLong(5, ptrnclsdt_completedtime);
864            
865            Long ptrnclsdt_validuntiltime = _value.getValidUntilTime();
866            if(ptrnclsdt_validuntiltime == null)
867                _ps.setNull(6, Types.BIGINT);
868            else
869                _ps.setLong(6, ptrnclsdt_validuntiltime);
870            
871            Long ptrnclsdt_fromtime = _value.getFromTime();
872            if(ptrnclsdt_fromtime == null)
873                _ps.setNull(7, Types.BIGINT);
874            else
875                _ps.setLong(7, ptrnclsdt_fromtime);
876            
877            Long ptrnclsdt_thrutime = _value.getThruTime();
878            if(ptrnclsdt_thrutime == null)
879                _ps.setNull(8, Types.BIGINT);
880            else
881                _ps.setLong(8, ptrnclsdt_thrutime);
882            
883            _ps.setLong(9, _value.getPrimaryKey().getEntityId());
884            
885            _value.clearHasBeenModified();
886        }
887        
888        return _hasBeenModified;
889    }
890    
891    @Override
892    public void store(Session session, PartyTrainingClassDetail entity)
893            throws PersistenceDatabaseException {
894        PreparedStatement _ps = session.prepareStatement(SQL_UPDATE);
895        
896        try {
897            PartyTrainingClassDetailValue _value = entity.getPartyTrainingClassDetailValue();
898            
899            if(bindForStore(_ps, _value)) {
900                if(PersistenceDebugFlags.CheckEntityUpdateRowCount) {
901                    int _count = _ps.executeUpdate();
902                    
903                    if(_count != 1) {
904                        throw new PersistenceDatabaseUpdateException("update failed, _count = " + _count);
905                    }
906                } else {
907                     _ps.executeUpdate();
908                }
909                
910                session.getValueCache().put(_value);
911            }
912        } catch (SQLException se) {
913            throw new PersistenceDatabaseException(se);
914        }
915    }
916    
917    @Override
918    public void store(Session session, Collection<PartyTrainingClassDetail> entities)
919            throws PersistenceDatabaseException {
920        if(entities.size() > 0) {
921            PreparedStatement _ps = session.prepareStatement(SQL_UPDATE);
922            int _modifiedEntities = 0;
923            
924            try {
925                for(PartyTrainingClassDetail entity : entities) {
926                    if(bindForStore(_ps, entity.getPartyTrainingClassDetailValue())) {
927                        _ps.addBatch();
928                        _modifiedEntities++;
929                    }
930                }
931                
932                if(_modifiedEntities != 0) {
933                    if(PersistenceDebugFlags.CheckEntityUpdateRowCount) {
934                        int[] _counts = _ps.executeBatch();
935                        
936                        for(int _countOffset = 0 ; _countOffset < _modifiedEntities  ; _countOffset++) {
937                            if(_counts[_countOffset] != 1 && _counts[_countOffset] != PreparedStatement.SUCCESS_NO_INFO) {
938                                throw new PersistenceDatabaseUpdateException("batch update failed, _counts[" + _countOffset + "] = " + _counts[_countOffset]);
939                            }
940                        }
941                    } else {
942                         _ps.executeBatch();
943                    }
944                    
945                    _ps.clearBatch();
946                    
947                    entities.forEach((entity) -> {
948                        session.getValueCache().put(entity.getPartyTrainingClassDetailValue());
949                    });
950                }
951            } catch (SQLException se) {
952                throw new PersistenceDatabaseException(se);
953            }
954        }
955    }
956    
957    @Override
958    public void store(Collection<PartyTrainingClassDetail> entities)
959            throws PersistenceDatabaseException {
960        store(ThreadSession.currentSession(), entities);
961    }
962    
963    @Override
964    public void remove(Session session, PartyTrainingClassDetail entity)
965            throws PersistenceDatabaseException {
966        remove(session, entity.getPrimaryKey());
967    }
968    
969    @Override
970    public void remove(Session session, PartyTrainingClassDetailPK pk)
971            throws PersistenceDatabaseException {
972        PreparedStatement _ps = session.prepareStatement(SQL_DELETE);
973        long _entityId = pk.getEntityId();
974        
975        try {
976            _ps.setLong(1, _entityId);
977            
978            if(PersistenceDebugFlags.CheckEntityDeleteRowCount) {
979                int _count = _ps.executeUpdate();
980                
981                if(_count != 1) {
982                    throw new PersistenceDatabaseUpdateException("remove failed, _count = " + _count);
983                }
984            } else {
985                 _ps.executeUpdate();
986            }
987            
988            session.getValueCache().remove(pk);
989        } catch (SQLException se) {
990            throw new PersistenceDatabaseException(se);
991        }
992        
993        session.removed(pk, false);
994    }
995    
996    @Override
997    public void remove(Session session, Collection<PartyTrainingClassDetailPK> pks)
998            throws PersistenceDatabaseException {
999        if(pks.size() > 0) {
1000            PreparedStatement _ps = session.prepareStatement(SQL_DELETE);
1001            int _modifiedEntities = 0;
1002            
1003            try {
1004                for(PartyTrainingClassDetailPK pk : pks) {
1005                    long _entityId = pk.getEntityId();
1006                    
1007                    _ps.setLong(1, _entityId);
1008                    
1009                    _ps.addBatch();
1010                    _modifiedEntities++;
1011                }
1012                
1013                if(_modifiedEntities != 0) {
1014                    if(PersistenceDebugFlags.CheckEntityDeleteRowCount) {
1015                        int[] _counts = _ps.executeBatch();
1016                        
1017                        for(int _countOffset = 0 ; _countOffset < _modifiedEntities  ; _countOffset++) {
1018                            if(_counts[_countOffset] != 1 && _counts[_countOffset] != PreparedStatement.SUCCESS_NO_INFO) {
1019                                throw new PersistenceDatabaseUpdateException("batch remove failed, _counts[" + _countOffset + "] = " + _counts[_countOffset]);
1020                            }
1021                        }
1022                    } else {
1023                        _ps.executeBatch();
1024                    }
1025                    
1026                    _ps.clearBatch();
1027                    
1028                    pks.forEach((pk) -> {
1029                        session.getValueCache().remove(pk);
1030                    });
1031                }
1032            } catch (SQLException se) {
1033                throw new PersistenceDatabaseException(se);
1034            }
1035            
1036            pks.forEach((pk) -> {
1037                session.removed(pk, true);
1038            });
1039        }
1040    }
1041    
1042    @Override
1043    public void remove(Collection<PartyTrainingClassDetailPK> pks)
1044            throws PersistenceDatabaseException {
1045        remove(ThreadSession.currentSession(), pks);
1046    }
1047    
1048    @Override
1049    public boolean validPK(Session session, PartyTrainingClassDetailPK pk)
1050            throws PersistenceDatabaseException {
1051        boolean valid = false;
1052        PreparedStatement _ps = session.prepareStatement(SQL_VALID);
1053        ResultSet _rs = null;
1054        
1055        try {
1056            _ps.setLong(1, pk.getEntityId());
1057            
1058            _rs = _ps.executeQuery();
1059            if(_rs.next()) {
1060                long _count = _rs.getLong(1);
1061                if(_rs.wasNull())
1062                    _count = 0;
1063                
1064                if(_count == 1)
1065                    valid = true;
1066            }
1067        } catch (SQLException se) {
1068            throw new PersistenceDatabaseException(se);
1069        } finally {
1070            if(_rs != null) {
1071                try {
1072                    _rs.close();
1073                } catch (SQLException se) {
1074                    // do nothing
1075                }
1076            }
1077        }
1078        
1079        return valid;
1080    }
1081    
1082}