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