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