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