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