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 * PartyApplicationEditorUseDetailFactory.java
021 */
022
023package com.echothree.model.data.party.server.factory;
024
025import com.echothree.model.data.party.common.pk.PartyApplicationEditorUsePK;
026import com.echothree.model.data.party.common.pk.PartyPK;
027import com.echothree.model.data.core.common.pk.ApplicationEditorUsePK;
028import com.echothree.model.data.core.common.pk.ApplicationEditorPK;
029
030import com.echothree.model.data.party.server.entity.PartyApplicationEditorUse;
031import com.echothree.model.data.party.server.entity.Party;
032import com.echothree.model.data.core.server.entity.ApplicationEditorUse;
033import com.echothree.model.data.core.server.entity.ApplicationEditor;
034
035import com.echothree.model.data.party.common.PartyApplicationEditorUseDetailConstants;
036import com.echothree.model.data.party.common.pk.PartyApplicationEditorUseDetailPK;
037import com.echothree.model.data.party.server.value.PartyApplicationEditorUseDetailValue;
038import com.echothree.model.data.party.server.entity.PartyApplicationEditorUseDetail;
039import com.echothree.util.common.exception.PersistenceDatabaseException;
040import com.echothree.util.common.exception.PersistenceDatabaseUpdateException;
041import com.echothree.util.common.exception.PersistenceNotNullException;
042import com.echothree.util.server.persistence.BaseFactory;
043import com.echothree.util.server.persistence.EntityIdGenerator;
044import com.echothree.util.server.persistence.EntityPermission;
045import com.echothree.util.server.persistence.PersistenceDebugFlags;
046import com.echothree.util.server.persistence.Session;
047import com.echothree.util.server.persistence.ThreadSession;
048import java.sql.PreparedStatement;
049import java.sql.ResultSet;
050import java.sql.SQLException;
051import java.sql.Types;
052import java.io.ByteArrayInputStream;
053import java.io.StringReader;
054import java.util.ArrayList;
055import java.util.Collection;
056import java.util.HashSet;
057import java.util.List;
058import java.util.Map;
059import java.util.Set;
060import javax.enterprise.context.ApplicationScoped;
061import javax.enterprise.inject.spi.CDI;
062import org.apache.commons.logging.Log;
063import org.apache.commons.logging.LogFactory;
064
065@ApplicationScoped
066public class PartyApplicationEditorUseDetailFactory
067        implements BaseFactory<PartyApplicationEditorUseDetailPK, PartyApplicationEditorUseDetail> {
068    
069    //final private static Log log = LogFactory.getLog(PartyApplicationEditorUseDetailFactory.class);
070    
071    final private static String SQL_SELECT_READ_ONLY = "SELECT parappledtrusedt_partyapplicationeditorusedetailid, parappledtrusedt_parappledtruse_partyapplicationeditoruseid, parappledtrusedt_par_partyid, parappledtrusedt_appledtruse_applicationeditoruseid, parappledtrusedt_appledtr_applicationeditorid, parappledtrusedt_preferredheight, parappledtrusedt_preferredwidth, parappledtrusedt_fromtime, parappledtrusedt_thrutime FROM partyapplicationeditorusedetails WHERE parappledtrusedt_partyapplicationeditorusedetailid = ?";
072    final private static String SQL_SELECT_READ_WRITE = "SELECT parappledtrusedt_partyapplicationeditorusedetailid, parappledtrusedt_parappledtruse_partyapplicationeditoruseid, parappledtrusedt_par_partyid, parappledtrusedt_appledtruse_applicationeditoruseid, parappledtrusedt_appledtr_applicationeditorid, parappledtrusedt_preferredheight, parappledtrusedt_preferredwidth, parappledtrusedt_fromtime, parappledtrusedt_thrutime FROM partyapplicationeditorusedetails WHERE parappledtrusedt_partyapplicationeditorusedetailid = ? FOR UPDATE";
073    final private static String SQL_INSERT = "INSERT INTO partyapplicationeditorusedetails (parappledtrusedt_partyapplicationeditorusedetailid, parappledtrusedt_parappledtruse_partyapplicationeditoruseid, parappledtrusedt_par_partyid, parappledtrusedt_appledtruse_applicationeditoruseid, parappledtrusedt_appledtr_applicationeditorid, parappledtrusedt_preferredheight, parappledtrusedt_preferredwidth, parappledtrusedt_fromtime, parappledtrusedt_thrutime) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
074    final private static String SQL_UPDATE = "UPDATE partyapplicationeditorusedetails SET parappledtrusedt_parappledtruse_partyapplicationeditoruseid = ?, parappledtrusedt_par_partyid = ?, parappledtrusedt_appledtruse_applicationeditoruseid = ?, parappledtrusedt_appledtr_applicationeditorid = ?, parappledtrusedt_preferredheight = ?, parappledtrusedt_preferredwidth = ?, parappledtrusedt_fromtime = ?, parappledtrusedt_thrutime = ? WHERE parappledtrusedt_partyapplicationeditorusedetailid = ?";
075    final private static String SQL_DELETE = "DELETE FROM partyapplicationeditorusedetails WHERE parappledtrusedt_partyapplicationeditorusedetailid = ?";
076    final private static String SQL_VALID = "SELECT COUNT(*) FROM partyapplicationeditorusedetails WHERE parappledtrusedt_partyapplicationeditorusedetailid = ?";
077    
078    final private static String PK_COLUMN = "parappledtrusedt_partyapplicationeditorusedetailid";
079    final private static String ALL_COLUMNS = "parappledtrusedt_partyapplicationeditorusedetailid, parappledtrusedt_parappledtruse_partyapplicationeditoruseid, parappledtrusedt_par_partyid, parappledtrusedt_appledtruse_applicationeditoruseid, parappledtrusedt_appledtr_applicationeditorid, parappledtrusedt_preferredheight, parappledtrusedt_preferredwidth, parappledtrusedt_fromtime, parappledtrusedt_thrutime";
080    final public static String TABLE_NAME = "partyapplicationeditorusedetails";
081    
082    final public static String PARAPPLEDTRUSEDT_PARTYAPPLICATIONEDITORUSEDETAILID = "parappledtrusedt_partyapplicationeditorusedetailid";
083    final public static String PARAPPLEDTRUSEDT_PARAPPLEDTRUSE_PARTYAPPLICATIONEDITORUSEID = "parappledtrusedt_parappledtruse_partyapplicationeditoruseid";
084    final public static String PARAPPLEDTRUSEDT_PAR_PARTYID = "parappledtrusedt_par_partyid";
085    final public static String PARAPPLEDTRUSEDT_APPLEDTRUSE_APPLICATIONEDITORUSEID = "parappledtrusedt_appledtruse_applicationeditoruseid";
086    final public static String PARAPPLEDTRUSEDT_APPLEDTR_APPLICATIONEDITORID = "parappledtrusedt_appledtr_applicationeditorid";
087    final public static String PARAPPLEDTRUSEDT_PREFERREDHEIGHT = "parappledtrusedt_preferredheight";
088    final public static String PARAPPLEDTRUSEDT_PREFERREDWIDTH = "parappledtrusedt_preferredwidth";
089    final public static String PARAPPLEDTRUSEDT_FROMTIME = "parappledtrusedt_fromtime";
090    final public static String PARAPPLEDTRUSEDT_THRUTIME = "parappledtrusedt_thrutime";
091    
092    final private static EntityIdGenerator entityIdGenerator = new EntityIdGenerator(PartyApplicationEditorUseDetailConstants.COMPONENT_VENDOR_NAME, PartyApplicationEditorUseDetailConstants.ENTITY_TYPE_NAME);
093    
094    /** Creates a new instance of PartyApplicationEditorUseDetailFactory */
095    protected PartyApplicationEditorUseDetailFactory() {
096        super();
097    }
098    
099    public static PartyApplicationEditorUseDetailFactory getInstance() {
100        return CDI.current().select(PartyApplicationEditorUseDetailFactory.class).get();
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 PartyApplicationEditorUseDetailConstants.COMPONENT_VENDOR_NAME;
121    }
122    
123    @Override
124    public String getEntityTypeName() {
125        return PartyApplicationEditorUseDetailConstants.ENTITY_TYPE_NAME;
126    }
127    
128    public PreparedStatement prepareStatement(String query) {
129        return ThreadSession.currentSession().prepareStatement(PartyApplicationEditorUseDetailFactory.class, query);
130    }
131    
132    public PartyApplicationEditorUseDetailPK getNextPK() {
133        return new PartyApplicationEditorUseDetailPK(entityIdGenerator.getNextEntityId());
134    }
135    
136    public Set<PartyApplicationEditorUseDetailPK> getPKsFromResultSetAsSet(ResultSet rs)
137            throws PersistenceDatabaseException {
138        Set<PartyApplicationEditorUseDetailPK> _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<PartyApplicationEditorUseDetailPK> getPKsFromResultSetAsList(ResultSet rs)
152            throws PersistenceDatabaseException {
153        java.util.List<PartyApplicationEditorUseDetailPK> _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 PartyApplicationEditorUseDetailPK getPKFromResultSet(ResultSet rs)
167            throws PersistenceDatabaseException {
168        PartyApplicationEditorUseDetailPK _result;
169        
170        try {
171            long parappledtrusedt_partyapplicationeditorusedetailid = rs.getLong(PARAPPLEDTRUSEDT_PARTYAPPLICATIONEDITORUSEDETAILID);
172            Long _entityId = rs.wasNull() ? null : parappledtrusedt_partyapplicationeditorusedetailid;
173            
174            _result = new PartyApplicationEditorUseDetailPK(_entityId);
175        } catch (SQLException se) {
176            throw new PersistenceDatabaseException(se);
177        }
178        
179        return _result;
180    }
181    
182    public java.util.List<PartyApplicationEditorUseDetailValue> getValuesFromPKs(Session session, Collection<PartyApplicationEditorUseDetailPK> pks)
183            throws PersistenceDatabaseException {
184        java.util.List<PartyApplicationEditorUseDetailValue> _values = new ArrayList<>(pks.size());
185        
186        for(PartyApplicationEditorUseDetailPK _pk: pks) {
187            _values.add(getValueFromPK(session, _pk));
188        }
189        
190        return _values;
191    }
192    
193    public PartyApplicationEditorUseDetailValue getValueFromPK(Session session, PartyApplicationEditorUseDetailPK pk)
194            throws PersistenceDatabaseException {
195        PartyApplicationEditorUseDetailValue _value;
196        
197        // See if we already have the entity in the session cache
198        PartyApplicationEditorUseDetail _entity = (PartyApplicationEditorUseDetail)session.getEntity(pk);
199        if(_entity == null)
200            _value = getEntityFromPK(session, EntityPermission.READ_ONLY, pk).getPartyApplicationEditorUseDetailValue();
201        else
202            _value = _entity.getPartyApplicationEditorUseDetailValue();
203        
204        return _value;
205    }
206    
207    public java.util.List<PartyApplicationEditorUseDetailValue> getValuesFromResultSet(Session session, ResultSet rs)
208            throws PersistenceDatabaseException {
209        java.util.List<PartyApplicationEditorUseDetailValue> _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 PartyApplicationEditorUseDetailValue getValueFromResultSet(Session session, ResultSet rs)
223            throws PersistenceDatabaseException {
224        PartyApplicationEditorUseDetailValue _value;
225        
226        try {
227            Long parappledtrusedt_partyapplicationeditorusedetailid = rs.getLong(PARAPPLEDTRUSEDT_PARTYAPPLICATIONEDITORUSEDETAILID);
228            PartyApplicationEditorUseDetailPK _pk = new PartyApplicationEditorUseDetailPK(parappledtrusedt_partyapplicationeditorusedetailid);
229            
230            // See if we already have the entity in the session cache
231            PartyApplicationEditorUseDetail _entity = (PartyApplicationEditorUseDetail)session.getEntity(_pk);
232            
233            if(_entity == null) {
234                Long parappledtrusedt_parappledtruse_partyapplicationeditoruseid = rs.getLong(PARAPPLEDTRUSEDT_PARAPPLEDTRUSE_PARTYAPPLICATIONEDITORUSEID);
235                if(rs.wasNull())
236                    parappledtrusedt_parappledtruse_partyapplicationeditoruseid = null;
237                
238                Long parappledtrusedt_par_partyid = rs.getLong(PARAPPLEDTRUSEDT_PAR_PARTYID);
239                if(rs.wasNull())
240                    parappledtrusedt_par_partyid = null;
241                
242                Long parappledtrusedt_appledtruse_applicationeditoruseid = rs.getLong(PARAPPLEDTRUSEDT_APPLEDTRUSE_APPLICATIONEDITORUSEID);
243                if(rs.wasNull())
244                    parappledtrusedt_appledtruse_applicationeditoruseid = null;
245                
246                Long parappledtrusedt_appledtr_applicationeditorid = rs.getLong(PARAPPLEDTRUSEDT_APPLEDTR_APPLICATIONEDITORID);
247                if(rs.wasNull())
248                    parappledtrusedt_appledtr_applicationeditorid = null;
249                
250                Integer parappledtrusedt_preferredheight = rs.getInt(PARAPPLEDTRUSEDT_PREFERREDHEIGHT);
251                if(rs.wasNull())
252                    parappledtrusedt_preferredheight = null;
253                
254                Integer parappledtrusedt_preferredwidth = rs.getInt(PARAPPLEDTRUSEDT_PREFERREDWIDTH);
255                if(rs.wasNull())
256                    parappledtrusedt_preferredwidth = null;
257                
258                Long parappledtrusedt_fromtime = rs.getLong(PARAPPLEDTRUSEDT_FROMTIME);
259                if(rs.wasNull())
260                    parappledtrusedt_fromtime = null;
261                
262                Long parappledtrusedt_thrutime = rs.getLong(PARAPPLEDTRUSEDT_THRUTIME);
263                if(rs.wasNull())
264                    parappledtrusedt_thrutime = null;
265                
266                _value = new PartyApplicationEditorUseDetailValue(_pk, new PartyApplicationEditorUsePK(parappledtrusedt_parappledtruse_partyapplicationeditoruseid), new PartyPK(parappledtrusedt_par_partyid), new ApplicationEditorUsePK(parappledtrusedt_appledtruse_applicationeditoruseid), new ApplicationEditorPK(parappledtrusedt_appledtr_applicationeditorid), parappledtrusedt_preferredheight, parappledtrusedt_preferredwidth, parappledtrusedt_fromtime, parappledtrusedt_thrutime);
267            } else
268                _value = _entity.getPartyApplicationEditorUseDetailValue();
269        } catch (SQLException se) {
270            throw new PersistenceDatabaseException(se);
271        }
272        
273        return _value;
274    }
275    
276    public java.util.List<PartyApplicationEditorUseDetail> getEntitiesFromPKs(EntityPermission entityPermission, Collection<PartyApplicationEditorUseDetailPK> pks)
277            throws PersistenceDatabaseException {
278        return getEntitiesFromPKs(ThreadSession.currentSession(), entityPermission, pks);
279    }
280    
281    public java.util.List<PartyApplicationEditorUseDetail> getEntitiesFromPKs(Session session, EntityPermission entityPermission, Collection<PartyApplicationEditorUseDetailPK> pks)
282            throws PersistenceDatabaseException {
283        java.util.List<PartyApplicationEditorUseDetail> _entities = new ArrayList<>(pks.size());
284        
285        for(PartyApplicationEditorUseDetailPK _pk: pks) {
286            _entities.add(getEntityFromPK(session, entityPermission, _pk));
287        }
288        
289        return _entities;
290    }
291    
292    public PartyApplicationEditorUseDetail getEntityFromValue(EntityPermission entityPermission, PartyApplicationEditorUseDetailValue value) {
293        return getEntityFromPK(ThreadSession.currentSession(), entityPermission, value.getPrimaryKey());
294    }
295    
296    public PartyApplicationEditorUseDetail getEntityFromValue(Session session, EntityPermission entityPermission, PartyApplicationEditorUseDetailValue value) {
297        return getEntityFromPK(session, entityPermission, value.getPrimaryKey());
298    }
299    
300    public PartyApplicationEditorUseDetail getEntityFromPK(EntityPermission entityPermission, PartyApplicationEditorUseDetailPK pk)
301            throws PersistenceDatabaseException {
302        return getEntityFromPK(ThreadSession.currentSession(), entityPermission, pk);
303    }
304    
305    public PartyApplicationEditorUseDetail getEntityFromCache(Session session, PartyApplicationEditorUseDetailPK pk) {
306        PartyApplicationEditorUseDetailValue _value = (PartyApplicationEditorUseDetailValue)session.getValueCache().get(pk);
307    
308        return _value == null ? null : new PartyApplicationEditorUseDetail(_value, EntityPermission.READ_ONLY);
309    }
310    
311    public PartyApplicationEditorUseDetail getEntityFromPK(Session session, EntityPermission entityPermission, PartyApplicationEditorUseDetailPK pk)
312            throws PersistenceDatabaseException {
313        PartyApplicationEditorUseDetail _entity;
314        
315        // See if we already have the entity in the session cache
316        _entity = (PartyApplicationEditorUseDetail)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<PartyApplicationEditorUseDetailPK> getPKsFromQueryAsSet(PreparedStatement ps, final Object... params)
359            throws PersistenceDatabaseException {
360        Set<PartyApplicationEditorUseDetailPK> _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<PartyApplicationEditorUseDetailPK> getPKsFromQueryAsList(PreparedStatement ps, final Object... params)
387            throws PersistenceDatabaseException {
388        java.util.List<PartyApplicationEditorUseDetailPK> _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 PartyApplicationEditorUseDetailPK getPKFromQuery(PreparedStatement ps, final Object... params)
415            throws PersistenceDatabaseException {
416        PartyApplicationEditorUseDetailPK _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<PartyApplicationEditorUseDetail> getEntitiesFromQuery(Session session, EntityPermission entityPermission, Map<EntityPermission, String>queryMap, final Object... params)
445            throws PersistenceDatabaseException {
446        PreparedStatement ps = session.prepareStatement(PartyApplicationEditorUseDetailFactory.class, queryMap.get(entityPermission));
447        
448        return getEntitiesFromQuery(session, entityPermission, ps, params);
449    }
450    
451    public java.util.List<PartyApplicationEditorUseDetail> getEntitiesFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap, final Object... params)
452            throws PersistenceDatabaseException {
453        Session session = ThreadSession.currentSession();
454        PreparedStatement ps = session.prepareStatement(PartyApplicationEditorUseDetailFactory.class, queryMap.get(entityPermission));
455        
456        return getEntitiesFromQuery(session, entityPermission, ps, params);
457    }
458    
459    public java.util.List<PartyApplicationEditorUseDetail> getEntitiesFromQuery(Session session, EntityPermission entityPermission, Map<EntityPermission, String>queryMap)
460            throws PersistenceDatabaseException {
461        PreparedStatement ps = session.prepareStatement(PartyApplicationEditorUseDetailFactory.class, queryMap.get(entityPermission));
462        
463        return getEntitiesFromQuery(session, entityPermission, ps);
464    }
465    
466    public java.util.List<PartyApplicationEditorUseDetail> getEntitiesFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap)
467            throws PersistenceDatabaseException {
468        Session session = ThreadSession.currentSession();
469        PreparedStatement ps = session.prepareStatement(PartyApplicationEditorUseDetailFactory.class, queryMap.get(entityPermission));
470        
471        return getEntitiesFromQuery(session, entityPermission, ps);
472    }
473    
474    public java.util.List<PartyApplicationEditorUseDetail> getEntitiesFromQuery(EntityPermission entityPermission, PreparedStatement ps)
475            throws PersistenceDatabaseException {
476        return getEntitiesFromQuery(ThreadSession.currentSession(), entityPermission, ps);
477    }
478    
479    public java.util.List<PartyApplicationEditorUseDetail> 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<PartyApplicationEditorUseDetail> getEntitiesFromQuery(Session session, EntityPermission entityPermission, PreparedStatement ps, final Object... params)
485            throws PersistenceDatabaseException {
486        java.util.List<PartyApplicationEditorUseDetail> _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 PartyApplicationEditorUseDetail getEntityFromQuery(Session session, EntityPermission entityPermission, Map<EntityPermission, String>queryMap, final Object... params)
513            throws PersistenceDatabaseException {
514        PreparedStatement ps = session.prepareStatement(PartyApplicationEditorUseDetailFactory.class, queryMap.get(entityPermission));
515        
516        return getEntityFromQuery(session, entityPermission, ps, params);
517    }
518    
519    public PartyApplicationEditorUseDetail getEntityFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap, final Object... params)
520            throws PersistenceDatabaseException {
521        Session session = ThreadSession.currentSession();
522        PreparedStatement ps = session.prepareStatement(PartyApplicationEditorUseDetailFactory.class, queryMap.get(entityPermission));
523        
524        return getEntityFromQuery(session, entityPermission, ps, params);
525    }
526    
527    public PartyApplicationEditorUseDetail getEntityFromQuery(Session session, EntityPermission entityPermission, Map<EntityPermission, String>queryMap)
528            throws PersistenceDatabaseException {
529        PreparedStatement ps = session.prepareStatement(PartyApplicationEditorUseDetailFactory.class, queryMap.get(entityPermission));
530        
531        return getEntityFromQuery(session, entityPermission, ps);
532    }
533    
534    public PartyApplicationEditorUseDetail getEntityFromQuery(EntityPermission entityPermission, Map<EntityPermission, String>queryMap)
535            throws PersistenceDatabaseException {
536        Session session = ThreadSession.currentSession();
537        PreparedStatement ps = session.prepareStatement(PartyApplicationEditorUseDetailFactory.class, queryMap.get(entityPermission));
538        
539        return getEntityFromQuery(session, entityPermission, ps);
540    }
541    
542    public PartyApplicationEditorUseDetail getEntityFromQuery(EntityPermission entityPermission, PreparedStatement ps)
543            throws PersistenceDatabaseException {
544        return getEntityFromQuery(ThreadSession.currentSession(), entityPermission, ps);
545    }
546    
547    public PartyApplicationEditorUseDetail getEntityFromQuery(EntityPermission entityPermission, PreparedStatement ps, final Object... params)
548            throws PersistenceDatabaseException {
549        return getEntityFromQuery(ThreadSession.currentSession(), entityPermission, ps, params);
550    }
551    
552    public PartyApplicationEditorUseDetail getEntityFromQuery(Session session, EntityPermission entityPermission, PreparedStatement ps, final Object... params)
553            throws PersistenceDatabaseException {
554        PartyApplicationEditorUseDetail _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<PartyApplicationEditorUseDetail> getEntitiesFromResultSet(EntityPermission entityPermission, ResultSet rs)
583            throws PersistenceDatabaseException {
584        return getEntitiesFromResultSet(ThreadSession.currentSession(), entityPermission, rs);
585    }
586    
587    public java.util.List<PartyApplicationEditorUseDetail> getEntitiesFromResultSet(Session session, EntityPermission entityPermission, ResultSet rs)
588            throws PersistenceDatabaseException {
589        java.util.List<PartyApplicationEditorUseDetail> _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 PartyApplicationEditorUseDetail getEntityFromResultSet(EntityPermission entityPermission, ResultSet rs)
603            throws PersistenceDatabaseException {
604        return getEntityFromResultSet(ThreadSession.currentSession(), entityPermission, rs);
605    }
606    
607    public PartyApplicationEditorUseDetail getEntityFromResultSet(Session session, EntityPermission entityPermission, ResultSet rs)
608            throws PersistenceDatabaseException {
609        PartyApplicationEditorUseDetail _entity;
610        
611        try {
612            Long parappledtrusedt_partyapplicationeditorusedetailid = rs.getLong(PARAPPLEDTRUSEDT_PARTYAPPLICATIONEDITORUSEDETAILID);
613            PartyApplicationEditorUseDetailPK _pk = new PartyApplicationEditorUseDetailPK(parappledtrusedt_partyapplicationeditorusedetailid);
614            
615            // See if we already have the entity in the session cache
616            _entity = (PartyApplicationEditorUseDetail)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 parappledtrusedt_parappledtruse_partyapplicationeditoruseid = rs.getLong(PARAPPLEDTRUSEDT_PARAPPLEDTRUSE_PARTYAPPLICATIONEDITORUSEID);
634                if(rs.wasNull())
635                    parappledtrusedt_parappledtruse_partyapplicationeditoruseid = null;
636                
637                Long parappledtrusedt_par_partyid = rs.getLong(PARAPPLEDTRUSEDT_PAR_PARTYID);
638                if(rs.wasNull())
639                    parappledtrusedt_par_partyid = null;
640                
641                Long parappledtrusedt_appledtruse_applicationeditoruseid = rs.getLong(PARAPPLEDTRUSEDT_APPLEDTRUSE_APPLICATIONEDITORUSEID);
642                if(rs.wasNull())
643                    parappledtrusedt_appledtruse_applicationeditoruseid = null;
644                
645                Long parappledtrusedt_appledtr_applicationeditorid = rs.getLong(PARAPPLEDTRUSEDT_APPLEDTR_APPLICATIONEDITORID);
646                if(rs.wasNull())
647                    parappledtrusedt_appledtr_applicationeditorid = null;
648                
649                Integer parappledtrusedt_preferredheight = rs.getInt(PARAPPLEDTRUSEDT_PREFERREDHEIGHT);
650                if(rs.wasNull())
651                    parappledtrusedt_preferredheight = null;
652                
653                Integer parappledtrusedt_preferredwidth = rs.getInt(PARAPPLEDTRUSEDT_PREFERREDWIDTH);
654                if(rs.wasNull())
655                    parappledtrusedt_preferredwidth = null;
656                
657                Long parappledtrusedt_fromtime = rs.getLong(PARAPPLEDTRUSEDT_FROMTIME);
658                if(rs.wasNull())
659                    parappledtrusedt_fromtime = null;
660                
661                Long parappledtrusedt_thrutime = rs.getLong(PARAPPLEDTRUSEDT_THRUTIME);
662                if(rs.wasNull())
663                    parappledtrusedt_thrutime = null;
664                
665                PartyApplicationEditorUseDetailValue _value = new PartyApplicationEditorUseDetailValue(_pk, parappledtrusedt_parappledtruse_partyapplicationeditoruseid == null? null: new PartyApplicationEditorUsePK(parappledtrusedt_parappledtruse_partyapplicationeditoruseid), parappledtrusedt_par_partyid == null? null: new PartyPK(parappledtrusedt_par_partyid), parappledtrusedt_appledtruse_applicationeditoruseid == null? null: new ApplicationEditorUsePK(parappledtrusedt_appledtruse_applicationeditoruseid), parappledtrusedt_appledtr_applicationeditorid == null? null: new ApplicationEditorPK(parappledtrusedt_appledtr_applicationeditorid), parappledtrusedt_preferredheight, parappledtrusedt_preferredwidth, parappledtrusedt_fromtime, parappledtrusedt_thrutime);
666                _entity = new PartyApplicationEditorUseDetail(_value, entityPermission);
667            }
668            
669            if(!foundInSessionCache) {
670                if(entityPermission.equals(EntityPermission.READ_ONLY)) {
671                    session.putReadOnlyEntity(_pk, _entity);
672                    session.getValueCache().put(_entity.getPartyApplicationEditorUseDetailValue());
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 PartyApplicationEditorUseDetail create(Session session, PartyApplicationEditorUse partyApplicationEditorUse, Party party, ApplicationEditorUse applicationEditorUse, ApplicationEditor applicationEditor, Integer preferredHeight, Integer preferredWidth, Long fromTime, Long thruTime)
685            throws PersistenceDatabaseException, PersistenceNotNullException {
686        return create(session, partyApplicationEditorUse == null ? null : partyApplicationEditorUse.getPrimaryKey(), party == null ? null : party.getPrimaryKey(), applicationEditorUse == null ? null : applicationEditorUse.getPrimaryKey(), applicationEditor == null ? null : applicationEditor.getPrimaryKey(), preferredHeight, preferredWidth, fromTime, thruTime);
687    }
688    
689    public PartyApplicationEditorUseDetail create(PartyApplicationEditorUse partyApplicationEditorUse, Party party, ApplicationEditorUse applicationEditorUse, ApplicationEditor applicationEditor, Integer preferredHeight, Integer preferredWidth, Long fromTime, Long thruTime)
690            throws PersistenceDatabaseException, PersistenceNotNullException {
691        return create(ThreadSession.currentSession(), partyApplicationEditorUse == null ? null : partyApplicationEditorUse.getPrimaryKey(), party == null ? null : party.getPrimaryKey(), applicationEditorUse == null ? null : applicationEditorUse.getPrimaryKey(), applicationEditor == null ? null : applicationEditor.getPrimaryKey(), preferredHeight, preferredWidth, fromTime, thruTime);
692    }
693    
694    private void bindForCreate(PreparedStatement _ps, PartyApplicationEditorUseDetailValue _value)
695            throws SQLException {
696        _ps.setLong(1, _value.getEntityId());
697        
698        PartyApplicationEditorUsePK parappledtrusedt_parappledtruse_partyapplicationeditoruseid = _value.getPartyApplicationEditorUsePK();
699        if(parappledtrusedt_parappledtruse_partyapplicationeditoruseid == null)
700            _ps.setNull(2, Types.BIGINT);
701        else
702            _ps.setLong(2, parappledtrusedt_parappledtruse_partyapplicationeditoruseid.getEntityId());
703            
704        PartyPK parappledtrusedt_par_partyid = _value.getPartyPK();
705        if(parappledtrusedt_par_partyid == null)
706            _ps.setNull(3, Types.BIGINT);
707        else
708            _ps.setLong(3, parappledtrusedt_par_partyid.getEntityId());
709            
710        ApplicationEditorUsePK parappledtrusedt_appledtruse_applicationeditoruseid = _value.getApplicationEditorUsePK();
711        if(parappledtrusedt_appledtruse_applicationeditoruseid == null)
712            _ps.setNull(4, Types.BIGINT);
713        else
714            _ps.setLong(4, parappledtrusedt_appledtruse_applicationeditoruseid.getEntityId());
715            
716        ApplicationEditorPK parappledtrusedt_appledtr_applicationeditorid = _value.getApplicationEditorPK();
717        if(parappledtrusedt_appledtr_applicationeditorid == null)
718            _ps.setNull(5, Types.BIGINT);
719        else
720            _ps.setLong(5, parappledtrusedt_appledtr_applicationeditorid.getEntityId());
721            
722        Integer parappledtrusedt_preferredheight = _value.getPreferredHeight();
723        if(parappledtrusedt_preferredheight == null)
724            _ps.setNull(6, Types.INTEGER);
725        else
726            _ps.setInt(6, parappledtrusedt_preferredheight);
727            
728        Integer parappledtrusedt_preferredwidth = _value.getPreferredWidth();
729        if(parappledtrusedt_preferredwidth == null)
730            _ps.setNull(7, Types.INTEGER);
731        else
732            _ps.setInt(7, parappledtrusedt_preferredwidth);
733            
734        Long parappledtrusedt_fromtime = _value.getFromTime();
735        if(parappledtrusedt_fromtime == null)
736            _ps.setNull(8, Types.BIGINT);
737        else
738            _ps.setLong(8, parappledtrusedt_fromtime);
739            
740        Long parappledtrusedt_thrutime = _value.getThruTime();
741        if(parappledtrusedt_thrutime == null)
742            _ps.setNull(9, Types.BIGINT);
743        else
744            _ps.setLong(9, parappledtrusedt_thrutime);
745            
746    }
747    
748    public PartyApplicationEditorUseDetail create(Session session, PartyApplicationEditorUsePK partyApplicationEditorUsePK, PartyPK partyPK, ApplicationEditorUsePK applicationEditorUsePK, ApplicationEditorPK applicationEditorPK, Integer preferredHeight, Integer preferredWidth, Long fromTime, Long thruTime)
749            throws PersistenceDatabaseException, PersistenceNotNullException {
750        PartyApplicationEditorUseDetailPK _pk = getNextPK();
751        PartyApplicationEditorUseDetailValue _value = new PartyApplicationEditorUseDetailValue(_pk, partyApplicationEditorUsePK, partyPK, applicationEditorUsePK, applicationEditorPK, preferredHeight, preferredWidth, 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        PartyApplicationEditorUseDetail _entity = new PartyApplicationEditorUseDetail(_value, EntityPermission.READ_ONLY);
774        session.putReadOnlyEntity(_pk, _entity);
775        
776        return _entity;
777    }
778    
779    public PartyApplicationEditorUseDetail create(PartyApplicationEditorUsePK partyApplicationEditorUsePK, PartyPK partyPK, ApplicationEditorUsePK applicationEditorUsePK, ApplicationEditorPK applicationEditorPK, Integer preferredHeight, Integer preferredWidth, Long fromTime, Long thruTime)
780            throws PersistenceDatabaseException, PersistenceNotNullException {
781        return create(ThreadSession.currentSession(), partyApplicationEditorUsePK, partyPK, applicationEditorUsePK, applicationEditorPK, preferredHeight, preferredWidth, fromTime, thruTime);
782    }
783    
784    public void create(Session session, Collection<PartyApplicationEditorUseDetailValue> _values)
785            throws PersistenceDatabaseException, PersistenceNotNullException {
786        int _size = _values.size();
787        
788        if(_size > 0) {
789            PreparedStatement _ps = session.prepareStatement(SQL_INSERT);
790            List<PartyApplicationEditorUseDetailValue> _cacheValues = new ArrayList<>(_size);
791            
792            try {
793                for(PartyApplicationEditorUseDetailValue _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                PartyApplicationEditorUseDetail _cacheEntity = new PartyApplicationEditorUseDetail(_cacheValue, EntityPermission.READ_ONLY);
821                
822                session.putReadOnlyEntity(_cacheValue.getPrimaryKey(), _cacheEntity);
823            });
824        }
825    }
826    
827    public void create(Collection<PartyApplicationEditorUseDetailValue> _values)
828            throws PersistenceDatabaseException, PersistenceNotNullException {
829        create(ThreadSession.currentSession(), _values);
830    }
831    
832    private boolean bindForStore(PreparedStatement _ps, PartyApplicationEditorUseDetailValue _value)
833            throws SQLException {
834        boolean _hasBeenModified = _value.hasBeenModified();
835        
836        if(_hasBeenModified) {
837            PartyApplicationEditorUsePK parappledtrusedt_parappledtruse_partyapplicationeditoruseid = _value.getPartyApplicationEditorUsePK();
838            if(parappledtrusedt_parappledtruse_partyapplicationeditoruseid == null)
839                _ps.setNull(1, Types.BIGINT);
840            else
841                _ps.setLong(1, parappledtrusedt_parappledtruse_partyapplicationeditoruseid.getEntityId());
842            
843            PartyPK parappledtrusedt_par_partyid = _value.getPartyPK();
844            if(parappledtrusedt_par_partyid == null)
845                _ps.setNull(2, Types.BIGINT);
846            else
847                _ps.setLong(2, parappledtrusedt_par_partyid.getEntityId());
848            
849            ApplicationEditorUsePK parappledtrusedt_appledtruse_applicationeditoruseid = _value.getApplicationEditorUsePK();
850            if(parappledtrusedt_appledtruse_applicationeditoruseid == null)
851                _ps.setNull(3, Types.BIGINT);
852            else
853                _ps.setLong(3, parappledtrusedt_appledtruse_applicationeditoruseid.getEntityId());
854            
855            ApplicationEditorPK parappledtrusedt_appledtr_applicationeditorid = _value.getApplicationEditorPK();
856            if(parappledtrusedt_appledtr_applicationeditorid == null)
857                _ps.setNull(4, Types.BIGINT);
858            else
859                _ps.setLong(4, parappledtrusedt_appledtr_applicationeditorid.getEntityId());
860            
861            Integer parappledtrusedt_preferredheight = _value.getPreferredHeight();
862            if(parappledtrusedt_preferredheight == null)
863                _ps.setNull(5, Types.INTEGER);
864            else
865                _ps.setInt(5, parappledtrusedt_preferredheight);
866            
867            Integer parappledtrusedt_preferredwidth = _value.getPreferredWidth();
868            if(parappledtrusedt_preferredwidth == null)
869                _ps.setNull(6, Types.INTEGER);
870            else
871                _ps.setInt(6, parappledtrusedt_preferredwidth);
872            
873            Long parappledtrusedt_fromtime = _value.getFromTime();
874            if(parappledtrusedt_fromtime == null)
875                _ps.setNull(7, Types.BIGINT);
876            else
877                _ps.setLong(7, parappledtrusedt_fromtime);
878            
879            Long parappledtrusedt_thrutime = _value.getThruTime();
880            if(parappledtrusedt_thrutime == null)
881                _ps.setNull(8, Types.BIGINT);
882            else
883                _ps.setLong(8, parappledtrusedt_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, PartyApplicationEditorUseDetail entity)
895            throws PersistenceDatabaseException {
896        PreparedStatement _ps = session.prepareStatement(SQL_UPDATE);
897        
898        try {
899            PartyApplicationEditorUseDetailValue _value = entity.getPartyApplicationEditorUseDetailValue();
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<PartyApplicationEditorUseDetail> 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(PartyApplicationEditorUseDetail entity : entities) {
928                    if(bindForStore(_ps, entity.getPartyApplicationEditorUseDetailValue())) {
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.getPartyApplicationEditorUseDetailValue());
951                    });
952                }
953            } catch (SQLException se) {
954                throw new PersistenceDatabaseException(se);
955            }
956        }
957    }
958    
959    @Override
960    public void store(Collection<PartyApplicationEditorUseDetail> entities)
961            throws PersistenceDatabaseException {
962        store(ThreadSession.currentSession(), entities);
963    }
964    
965    @Override
966    public void remove(Session session, PartyApplicationEditorUseDetail entity)
967            throws PersistenceDatabaseException {
968        remove(session, entity.getPrimaryKey());
969    }
970    
971    @Override
972    public void remove(Session session, PartyApplicationEditorUseDetailPK 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<PartyApplicationEditorUseDetailPK> 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(PartyApplicationEditorUseDetailPK 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<PartyApplicationEditorUseDetailPK> pks)
1046            throws PersistenceDatabaseException {
1047        remove(ThreadSession.currentSession(), pks);
1048    }
1049    
1050    @Override
1051    public boolean validPK(Session session, PartyApplicationEditorUseDetailPK 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}