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