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