HHH-12076 - Query not built properly when joining a table based on class

Add replicating test case for HBM mappings
This commit is contained in:
randymay 2017-11-03 16:22:22 -04:00 committed by Vlad Mihalcea
parent 26ae3c6726
commit a5d50c3bd5
21 changed files with 1797 additions and 2 deletions

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.query;
package org.hibernate.query.hhh12076;
import java.util.Date;
import java.util.HashMap;
@ -43,7 +43,7 @@ import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
import static org.junit.Assert.assertNotNull;
@TestForIssue(jiraKey = "HHH-12076")
public class HQLJoinClassTest extends BaseCoreFunctionalTestCase {
public class AnnotationMappingJoinClassTest extends BaseCoreFunctionalTestCase {
@Override
protected Class[] getAnnotatedClasses() {

View File

@ -0,0 +1,223 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.query.hhh12076;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class Claim {
public static final long serialVersionUID = 1L;
private Long _id;
private Date _creationDate;
private Date _modifiedDate;
private Integer _version;
private Long _trackingId;
private Integer _term;
private Double _initialReserve = 0.0;
private Date _effectiveDate;
private Date _expiryDate;
private Date _notificationDate;
private Date _pendingDate;
private Date _openDate;
private Date _suspendDate;
private Date _closeDate;
private String _externalId;
private String _importRef;
private String _location;
private Set<Extension> _extensions;
private Set<Settlement> _settlements;
private transient volatile Map<Class<?>, Extension> _extensionMap;
/**
* default constructor
*/
public Claim() {
_extensions = new HashSet<Extension>();
_settlements = new HashSet<Settlement>();
}
public Claim getClaim() {
return this;
}
public void addExtension(Extension extension) {
_extensions.add( extension );
extension.setClaim( this );
}
public void addSettlement(Settlement settlement) {
_settlements.add( settlement );
settlement.setClaim( this );
}
public Long getId() {
return _id;
}
public void setId(Long id) {
_id = id;
}
public Date getCreationDate() {
return _creationDate;
}
public void setCreationDate(Date creationDate) {
_creationDate = creationDate;
}
public Date getModifiedDate() {
return _modifiedDate;
}
public void setModifiedDate(Date modifiedDate) {
_modifiedDate = modifiedDate;
}
public Integer getVersion() {
return _version;
}
public void setVersion(Integer version) {
_version = version;
}
public Long getTrackingId() {
return _trackingId;
}
public void setTrackingId(Long trackingId) {
_trackingId = trackingId;
}
public String getExternalId() {
return _externalId;
}
public void setExternalId(String externalId) {
_externalId = externalId;
}
public Date getEffectiveDate() {
return _effectiveDate;
}
public void setEffectiveDate(Date effectiveDate) {
_effectiveDate = effectiveDate;
}
public Date getExpiryDate() {
return _expiryDate;
}
public void setExpiryDate(Date expiryDate) {
_expiryDate = expiryDate;
}
public Set<Extension> getExtensions() {
return _extensions;
}
public void setExtensions(Set<Extension> extensions) {
_extensions = extensions;
}
public Set<Settlement> getSettlements() {
return _settlements;
}
public void setSettlements(Set<Settlement> settlements) {
_settlements = settlements;
}
public Date getNotificationDate() {
return _notificationDate;
}
public void setNotificationDate(Date notificationDate) {
_notificationDate = notificationDate;
}
public Date getOpenDate() {
return _openDate;
}
public void setOpenDate(Date openDate) {
_openDate = openDate;
}
public Date getCloseDate() {
return _closeDate;
}
public void setCloseDate(Date closeDate) {
_closeDate = closeDate;
}
public Double getInitialReserve() {
return _initialReserve;
}
public void setInitialReserve(Double initialReserve) {
_initialReserve = initialReserve;
}
public String getLocation() {
return _location;
}
public void setLocation(String location) {
_location = location;
}
public String getImportRef() {
return _importRef;
}
public void setImportRef(String importRef) {
_importRef = importRef;
}
public Date getPendingDate() {
return _pendingDate;
}
public void setPendingDate(Date startDate) {
_pendingDate = startDate;
}
public Date getSuspendDate() {
return _suspendDate;
}
public void setSuspendDate(Date suspendDate) {
_suspendDate = suspendDate;
}
@SuppressWarnings("unchecked")
public <X extends Extension> X getExtension(Class<X> extensionType) {
if ( _extensionMap == null || _extensionMap.size() != _extensions.size() ) {
Map<Class<?>, Extension> map = new HashMap<Class<?>, Extension>( _extensions.size() );
map = new HashMap<Class<?>, Extension>( _extensions.size() );
for ( Extension extension : _extensions ) {
map.put( extension.getClass(), extension );
}
_extensionMap = map;
}
return (X) _extensionMap.get( extensionType );
}
}

View File

@ -0,0 +1,213 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.query.hhh12076;
public class EwtAssessmentExtension extends SettlementExtension {
public static final long serialVersionUID = 1L;
public static final String PROPERTY_DETAIL_OPTIONS = "detail_options";
public static final String PROPERTY_DAMAGE_TYPE_OPTIONS = "damage_type_options";
public static final String PROPERTY_EXCLUSION_OPTIONS = "exclusion_options";
public static final String PROPERTY_OVERRIDE_ENABLED = "override_enabled";
private Double _requestedUnits = -1.0; //2
private Double _requestedUnitAmount = -1.0; //$150
private Double _requestedSubtotal = 0.0; //$300
private Double _requestedTaxAmount = 0.0; //$30
private Double _requestedTotal = 0.0; //$330
private Double _coveredRatio = 0.0;
private Double _coveredUnits = 0.0;
private Double _coveredUnitAmount = 0.0;
private Double _coveredUnitAmountOverride = 0.0;
private Double _coveredSubtotal = 0.0;
private Double _coveredTaxAmount = 0.0;
private Double _coveredTotal = 0.0;
private Double _underinsuredAmount = 0.0;
private Double _shortfallUnitAmount = 0.0;
private Double _shortfallTotal = 0.0;
private Double _taxRate = 0.0;
private String _details;
private String _damageType;
private String _exclusion;
private Boolean _validInspection;
private Boolean _taxExempt = false;
public EwtAssessmentExtension() {
}
public Double getRequestedUnits() {
return _requestedUnits;
}
public void setRequestedUnits(Double requestedUnits) {
_requestedUnits = requestedUnits;
}
public Double getRequestedUnitAmount() {
return _requestedUnitAmount;
}
public void setRequestedUnitAmount(Double requestedBenefitPerUnit) {
_requestedUnitAmount = requestedBenefitPerUnit;
}
public Double getRequestedSubtotal() {
return _requestedSubtotal;
}
public void setRequestedSubtotal(Double requestedBenefitSubtotal) {
_requestedSubtotal = requestedBenefitSubtotal;
}
public Double getRequestedTaxAmount() {
return _requestedTaxAmount;
}
public void setRequestedTaxAmount(Double requestedBenefitTax) {
_requestedTaxAmount = requestedBenefitTax;
}
public Double getRequestedTotal() {
return _requestedTotal;
}
public void setRequestedTotal(Double requestedBenefitTotal) {
_requestedTotal = requestedBenefitTotal;
}
public Double getCoveredUnitAmount() {
return _coveredUnitAmount;
}
public void setCoveredUnitAmount(Double coveredBenefitPerUnit) {
_coveredUnitAmount = coveredBenefitPerUnit;
}
public Double getCoveredSubtotal() {
return _coveredSubtotal;
}
public void setCoveredSubtotal(Double coveredBenefitSubtotal) {
_coveredSubtotal = coveredBenefitSubtotal;
}
public Double getCoveredTaxAmount() {
return _coveredTaxAmount;
}
public void setCoveredTaxAmount(Double coveredTaxAmount) {
_coveredTaxAmount = coveredTaxAmount;
}
public Double getCoveredTotal() {
return _coveredTotal;
}
public void setCoveredTotal(Double coveredBenefitTotal) {
_coveredTotal = coveredBenefitTotal;
}
public Double getTaxRate() {
return _taxRate;
}
public void setTaxRate(Double taxRate) {
_taxRate = taxRate;
}
public Double getShortfallUnitAmount() {
return _shortfallUnitAmount;
}
public void setShortfallUnitAmount(Double shortfallUnitAmount) {
_shortfallUnitAmount = shortfallUnitAmount;
}
public Double getShortfallTotal() {
return _shortfallTotal;
}
public void setShortfallTotal(Double shortfallTotal) {
_shortfallTotal = shortfallTotal;
}
public String getDetails() {
return _details;
}
public void setDetails(String description) {
_details = description;
}
public Double getUnderinsuredAmount() {
return _underinsuredAmount;
}
public void setUnderinsuredAmount(Double truncatedAmount) {
_underinsuredAmount = truncatedAmount;
}
public Double getCoveredUnits() {
return _coveredUnits;
}
public void setCoveredUnits(Double coveredUnits) {
_coveredUnits = coveredUnits;
}
public String getDamageType() {
return _damageType;
}
public void setDamageType(String damageType) {
_damageType = damageType;
}
public Double getCoveredRatio() {
return _coveredRatio;
}
public void setCoveredRatio(Double coveredRatio) {
_coveredRatio = coveredRatio;
}
public String getExclusion() {
return _exclusion;
}
public void setExclusion(String exclusion) {
_exclusion = exclusion;
}
public Double getCoveredUnitAmountOverride() {
return _coveredUnitAmountOverride;
}
public void setCoveredUnitAmountOverride(Double coveredUnitOverride) {
_coveredUnitAmountOverride = coveredUnitOverride;
}
public Boolean isValidInspection() {
return _validInspection;
}
public void setValidInspection(Boolean validInspection) {
_validInspection = validInspection;
}
public Boolean isTaxExempt() {
return _taxExempt;
}
public void setTaxExempt(Boolean taxExempt) {
_taxExempt = taxExempt;
}
}

View File

@ -0,0 +1,76 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.query.hhh12076;
import java.util.Date;
public abstract class Extension {
public static final long serialVersionUID = 1L;
private Long _id;
private Date _creationDate;
private Date _modifiedDate;
private Integer _version;
private String _type;
private Claim _claim;
public Extension() {
String[] name = this.getClass().getName().split( "\\." );
_type = name[name.length - 1];
}
public Long getId() {
return _id;
}
protected void setId(Long id) {
_id = id;
}
public Date getCreationDate() {
return _creationDate;
}
public void setCreationDate(Date creationDate) {
_creationDate = creationDate;
}
public Date getModifiedDate() {
return _modifiedDate;
}
public void setModifiedDate(Date modifiedDate) {
_modifiedDate = modifiedDate;
}
public Integer getVersion() {
return _version;
}
public void setVersion(Integer version) {
_version = version;
}
public Claim getClaim() {
return _claim;
}
public void setClaim(Claim claim) {
_claim = claim;
}
public String getType() {
return _type;
}
public void setType(String type) {
_type = type;
}
}

View File

@ -0,0 +1,48 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.query.hhh12076;
public class GapAssessmentExtension extends SettlementExtension {
public static final long serialVersionUID = 1L;
private Double _insuredsObligation = 0.0;
private Double _eligibleAmount = 0.0;
private Double _assessedAmount = 0.0;
private Double _underinsuredAmount = 0.0;
public Double getAssessedAmount() {
return _assessedAmount;
}
public void setAssessedAmount(Double assessedAmount) {
_assessedAmount = assessedAmount;
}
public Double getEligibleAmount() {
return _eligibleAmount;
}
public void setEligibleAmount(Double eligible) {
_eligibleAmount = eligible;
}
public Double getUnderinsuredAmount() {
return _underinsuredAmount;
}
public void setUnderinsuredAmount(Double underinsuredAmount) {
_underinsuredAmount = underinsuredAmount;
}
public Double getInsuredsObligation() {
return _insuredsObligation;
}
public void setInsuredsObligation(Double insuredsObligation) {
_insuredsObligation = insuredsObligation;
}
}

View File

@ -0,0 +1,102 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.query.hhh12076;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.query.Query;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@TestForIssue(jiraKey = "HHH-12076")
public class HbmMappingJoinClassTest extends BaseCoreFunctionalTestCase {
@Override
protected String[] getMappings() {
return new String[] {
"Claim.hbm.xml",
"EwtAssessmentExtension.hbm.xml",
"Extension.hbm.xml",
"GapAssessmentExtension.hbm.xml",
"Settlement.hbm.xml",
"SettlementExtension.hbm.xml",
"SettlementTask.hbm.xml",
"Task.hbm.xml",
"TaskStatus.hbm.xml",
};
}
@Override
protected String getBaseForMappings() {
return "org/hibernate/query/hhh12076/";
}
@Override
protected void prepareTest() {
doInHibernate( this::sessionFactory, session -> {
TaskStatus taskStatus = new TaskStatus();
taskStatus.setName("Enabled");
taskStatus.setDisplayName("Enabled");
session.save(taskStatus);
for (long i = 0; i < 10; i++) {
SettlementTask settlementTask = new SettlementTask();
settlementTask.setId(i);
Settlement settlement = new Settlement();
settlementTask.setLinked(settlement);
settlementTask.setStatus(taskStatus);
Claim claim = new Claim();
claim.setId(i);
settlement.setClaim(claim);
for (int j = 0; j < 2; j++) {
GapAssessmentExtension gapAssessmentExtension = new GapAssessmentExtension();
gapAssessmentExtension.setSettlement(settlement);
EwtAssessmentExtension ewtAssessmentExtension = new EwtAssessmentExtension();
ewtAssessmentExtension.setSettlement(settlement);
settlement.getExtensions().add(gapAssessmentExtension);
settlement.getExtensions().add(ewtAssessmentExtension);
}
session.save(claim);
session.save(settlement);
session.save(settlementTask);
}
} );
}
@Test
@FailureExpected( jiraKey = "HHH-12076")
public void testClassExpressionInOnClause() {
doInHibernate( this::sessionFactory, session -> {
List<SettlementTask> results = session.createQuery(
"select " +
" rootAlias.id, " +
" linked.id, " +
" extensions.id " +
"from SettlementTask as rootAlias " +
"join rootAlias.linked as linked " +
"left join linked.extensions as extensions " +
" on extensions.class = org.hibernate.query.hhh12076.EwtAssessmentExtension " +
"where linked.id = :claimId")
.setParameter("claimId", 1L)
.getResultList();
assertNotNull(results);
} );
}
}

View File

@ -0,0 +1,256 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.query.hhh12076;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class Settlement {
private Long _id;
private Integer _version;
private Date _creationDate;
private Date _modifiedDate;
private Boolean _override = false;
private Boolean _started = false;
private Boolean _taxable = false;
private Double _units = 0.0;
private Double _amount = 0.0;
private Double _subtotal = 0.0;
private Double _taxRate = 0.0;
private Double _taxAmount = 0.0;
private Double _goodwill = 0.0;
private Double _totalAmount = 0.0;
private Double _underinsuredAmount = 0.0;
private Date _openDate;
private Date _allocateDate;
private Date _closeDate;
private String _trackingId;
private Claim _claim;
private SettlementStatus _status = SettlementStatus.RESERVED;
private Set<SettlementExtension> _extensions;
private transient Map<Class<?>, SettlementExtension> _extensionMap;
public Settlement() {
_extensions = new HashSet<SettlementExtension>();
}
public Long getId() {
return _id;
}
protected void setId(Long id) {
_id = id;
}
public Integer getVersion() {
return _version;
}
public void setVersion(Integer version) {
_version = version;
}
public Date getCreationDate() {
return _creationDate;
}
public void setCreationDate(Date creationDate) {
_creationDate = creationDate;
}
public Date getModifiedDate() {
return _modifiedDate;
}
public void setModifiedDate(Date modifiedDate) {
_modifiedDate = modifiedDate;
}
public Claim getClaim() {
return _claim;
}
public void setClaim(Claim claim) {
_claim = claim;
}
public SettlementStatus getStatus() {
return _status;
}
public void setStatus(SettlementStatus status) {
_status = status;
}
public String getTrackingId() {
return _trackingId;
}
public void setTrackingId(String trackingId) {
_trackingId = trackingId;
}
public Double getUnits() {
return _units;
}
public void setUnits(Double units) {
_units = units;
}
public Double getAmount() {
return _amount;
}
public void setAmount(Double amount) {
_amount = amount;
}
public Double getTotalAmount() {
return _totalAmount;
}
public void setTotalAmount(Double totalAmount) {
_totalAmount = totalAmount;
}
public Date getCloseDate() {
return _closeDate;
}
public void setCloseDate(Date settlementDate) {
_closeDate = settlementDate;
}
public Set<SettlementExtension> getExtensions() {
return _extensions;
}
public void setExtensions(Set<SettlementExtension> extensions) {
_extensions = extensions;
}
public void addExtension(SettlementExtension extension) {
if ( !hasExtension( extension.getClass() ) ) {
if ( extension.getOrderIndex() == null ) {
extension.setOrderIndex( _extensions.size() );
}
extension.setSettlement( this );
_extensions.add( extension );
}
}
@SuppressWarnings("unchecked")
public <X extends SettlementExtension> X getExtension(Class<X> extensionType) {
if ( _extensionMap == null || _extensionMap.size() != _extensions.size() ) {
Map<Class<?>, SettlementExtension> map = new HashMap<Class<?>, SettlementExtension>( _extensions.size() );
for ( SettlementExtension extension : _extensions ) {
map.put( extension.getClass(), extension );
}
_extensionMap = map;
}
return (X) _extensionMap.get( extensionType );
}
public <X extends SettlementExtension> boolean hasExtension(Class<X> extensionType) {
return getExtension( extensionType ) != null;
}
public Boolean isOverride() {
return _override;
}
public void setOverride(Boolean override) {
_override = override;
}
public Double getGoodwill() {
return _goodwill;
}
public void setGoodwill(Double goodwill) {
_goodwill = goodwill;
}
public Date getOpenDate() {
return _openDate;
}
public void setOpenDate(Date startDate) {
_openDate = startDate;
}
public Date getAllocateDate() {
return _allocateDate;
}
public void setAllocateDate(Date allocateDate) {
_allocateDate = allocateDate;
}
public Double getSubtotal() {
return _subtotal;
}
public void setSubtotal(Double subtotal) {
_subtotal = subtotal;
}
public Double getTaxRate() {
return _taxRate;
}
public void setTaxRate(Double taxRate) {
_taxRate = taxRate;
}
public Double getTaxAmount() {
return _taxAmount;
}
public void setTaxAmount(Double taxAmount) {
_taxAmount = taxAmount;
}
public Double getUnderinsuredAmount() {
return _underinsuredAmount;
}
public void setUnderinsuredAmount(Double underinsuredAmount) {
_underinsuredAmount = underinsuredAmount;
}
public Boolean isStarted() {
return _started;
}
public void setStarted(Boolean started) {
_started = started;
}
public Boolean isTaxable() {
return _taxable;
}
public void setTaxable(Boolean taxable) {
_taxable = taxable;
}
}

View File

@ -0,0 +1,76 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.query.hhh12076;
import java.util.Date;
public abstract class SettlementExtension {
private Long _id;
private Integer _version;
private Date _creationDate;
private Date _modifiedDate;
private Integer _orderIndex;
private Settlement _settlement;
public SettlementExtension() {
}
public Claim getClaim() {
return _settlement.getClaim();
}
public Long getId() {
return _id;
}
protected void setId(Long id) {
_id = id;
}
public Integer getVersion() {
return _version;
}
public void setVersion(Integer version) {
_version = version;
}
public Date getCreationDate() {
return _creationDate;
}
public void setCreationDate(Date creationDate) {
_creationDate = creationDate;
}
public Date getModifiedDate() {
return _modifiedDate;
}
public void setModifiedDate(Date modifiedDate) {
_modifiedDate = modifiedDate;
}
public Settlement getSettlement() {
return _settlement;
}
public void setSettlement(Settlement settlement) {
_settlement = settlement;
}
public Integer getOrderIndex() {
return _orderIndex;
}
public void setOrderIndex(Integer orderIndex) {
_orderIndex = orderIndex;
}
}

View File

@ -0,0 +1,11 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.query.hhh12076;
public enum SettlementStatus {
RESERVED, ALLOCATED, PAID, VOID, DENIED
}

View File

@ -0,0 +1,21 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.query.hhh12076;
public class SettlementTask extends Task<Settlement> {
private Settlement _linked;
public Settlement getLinked() {
return _linked;
}
public void setLinked(Settlement settlement) {
_linked = settlement;
}
}

View File

@ -0,0 +1,182 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.query.hhh12076;
import java.util.Date;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
public abstract class Task<T> {
private Long _id;
private Integer _version;
private Date _creationDate;
private Date _modifiedDate;
private Date _startDate;
private Date _closeDate;
private Date _dueDate;
private Date _stateDueDate;
private Date _statusDueDate;
private Date _stateTransitionDate;
private Date _statusTransitionDate;
private Task<?> _parent;
private TaskStatus _status;
private Set<Task<?>> _children;
private Set<Task<?>> _linkedTasks;
public Task() {
_children = new HashSet<Task<?>>();
_linkedTasks = new HashSet<Task<?>>();
}
public abstract T getLinked();
public abstract void setLinked(T linked);
public void addChild(Task<?> task) {
task.setParent( this );
_children.add( task );
}
public Long getId() {
return _id;
}
public void setId(Long id) {
_id = id;
}
public Integer getVersion() {
return _version;
}
public void setVersion(Integer version) {
_version = version;
}
public Date getCreationDate() {
return _creationDate;
}
public void setCreationDate(Date creationDate) {
_creationDate = creationDate;
}
public Date getModifiedDate() {
return _modifiedDate;
}
public void setModifiedDate(Date modifiedDate) {
_modifiedDate = modifiedDate;
}
public TaskStatus getStatus() {
return _status;
}
public void setStatus(TaskStatus status) {
_status = status;
}
@SuppressWarnings("unchecked")
public <X extends Task<?>> Set<X> getChildren(Class<X> ofType) {
Set<X> children = null;
children = new LinkedHashSet<X>();
for ( Task<?> child : _children ) {
if ( ofType.isInstance( child ) ) {
children.add( (X) child );
}
}
return children;
}
public Set<Task<?>> getChildren() {
return _children;
}
public void setChildren(Set<Task<?>> links) {
_children = links;
}
public Date getStartDate() {
return _startDate;
}
public void setStartDate(Date openDate) {
_startDate = openDate;
}
public Date getCloseDate() {
return _closeDate;
}
public void setCloseDate(Date closeDate) {
_closeDate = closeDate;
}
public Date getDueDate() {
return _dueDate;
}
public void setDueDate(Date expiryDate) {
_dueDate = expiryDate;
}
public Task<?> getParent() {
return _parent;
}
public void setParent(Task<?> parentTask) {
_parent = parentTask;
}
public Set<Task<?>> getLinkedTasks() {
return _linkedTasks;
}
public void setLinkedTasks(Set<Task<?>> linkedTasks) {
_linkedTasks = linkedTasks;
}
public Date getStateTransitionDate() {
return _stateTransitionDate;
}
public void setStateTransitionDate(Date stateTransitionDate) {
_stateTransitionDate = stateTransitionDate;
}
public Date getStatusTransitionDate() {
return _statusTransitionDate;
}
public void setStatusTransitionDate(Date taskTransitionDate) {
_statusTransitionDate = taskTransitionDate;
}
public Date getStateDueDate() {
return _stateDueDate;
}
public void setStateDueDate(Date stateDueDate) {
_stateDueDate = stateDueDate;
}
public Date getStatusDueDate() {
return _statusDueDate;
}
public void setStatusDueDate(Date statusDueDate) {
_statusDueDate = statusDueDate;
}
}

View File

@ -0,0 +1,131 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.query.hhh12076;
import java.util.Date;
public class TaskStatus {
private Long _id;
private Integer _version;
private Date _creationDate;
private Date _modifiedDate;
private boolean _active;
private Integer _orderIndex;
private String _name;
private String _displayName;
public TaskStatus() {
}
public String getEntityName() {
return _displayName;
}
public Long getId() {
return _id;
}
public void setId(Long id) {
_id = id;
}
public Integer getVersion() {
return _version;
}
public void setVersion(Integer version) {
_version = version;
}
public Date getCreationDate() {
return _creationDate;
}
public void setCreationDate(Date creationDate) {
_creationDate = creationDate;
}
public Date getModifiedDate() {
return _modifiedDate;
}
public void setModifiedDate(Date modifiedDate) {
_modifiedDate = modifiedDate;
}
public String getName() {
return _name;
}
public void setName(String name) {
_name = name;
}
public String getDisplayName() {
return _displayName;
}
public void setDisplayName(String displayName) {
_displayName = displayName;
}
public boolean isActive() {
return _active;
}
public void setActive(boolean active) {
_active = active;
}
@Override
public String toString() {
return _name;
}
public Integer getOrderIndex() {
return _orderIndex;
}
public void setOrderIndex(Integer ordering) {
_orderIndex = ordering;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ( ( _name == null ) ? 0 : _name.hashCode() );
return result;
}
@Override
public boolean equals(Object obj) {
if ( obj == null ) {
return false;
}
if ( obj == this ) {
return true;
}
if ( !( obj instanceof TaskStatus ) ) {
return false;
}
TaskStatus other = (TaskStatus) obj;
if ( _name == null ) {
if ( other._name != null ) {
return false;
}
}
else if ( !_name.equals( other._name ) ) {
return false;
}
return true;
}
}

View File

@ -0,0 +1,86 @@
<?xml version="1.0"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class
name="org.hibernate.query.hhh12076.Claim"
table="claim"
lazy="false">
<id name="id" type="java.lang.Long">
<column name="id"/>
<generator class="native"/>
</id>
<version name="version" unsaved-value="null" type="java.lang.Integer"/>
<property name="creationDate" type="timestamp" insert="false" update="false" generated="always">
<column name="creation_date"/>
</property>
<property name="modifiedDate" type="timestamp" insert="false" update="false" generated="always">
<column name="modified_date"/>
</property>
<property name="externalId" type="java.lang.String">
<column name="external_id" length="255"/>
</property>
<property name="location" type="java.lang.String">
<column name="location" length="255"/>
</property>
<property name="importRef" type="java.lang.String">
<column name="import_ref" length="255"/>
</property>
<property name="effectiveDate" type="java.util.Date">
<column name="effective_date"/>
</property>
<property name="expiryDate" type="java.util.Date">
<column name="expiry_date"/>
</property>
<property name="notificationDate" type="java.util.Date">
<column name="notification_date"/>
</property>
<property name="pendingDate" type="java.util.Date">
<column name="pending_date"/>
</property>
<property name="openDate" type="java.util.Date">
<column name="open_date"/>
</property>
<property name="suspendDate" type="java.util.Date">
<column name="suspend_date"/>
</property>
<property name="closeDate" type="java.util.Date">
<column name="close_date"/>
</property>
<set
name="extensions"
table="claim_extension"
inverse="true"
lazy="extra"
batch-size="10"
cascade="all, delete-orphan">
<key>
<column name="claim_id" not-null="true"/>
</key>
<one-to-many class="org.hibernate.query.hhh12076.Extension"/>
</set>
<set
name="settlements"
table="claim_settlement"
inverse="true"
lazy="extra"
batch-size="10"
cascade="all, delete-orphan">
<key>
<column name="claim_id" not-null="true"/>
</key>
<one-to-many class="org.hibernate.query.hhh12076.Settlement"/>
</set>
</class>
</hibernate-mapping>

View File

@ -0,0 +1,31 @@
<?xml version="1.0"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<joined-subclass
name="org.hibernate.query.hhh12076.EwtAssessmentExtension"
extends="org.hibernate.query.hhh12076.SettlementExtension"
table="claim_settlement_ext_i3_ewt"
lazy="false">
<key>
<column name="extension_id" not-null="true"/>
</key>
<property name="details" type="java.lang.String">
<column name="details" length="255"/>
</property>
<property name="damageType" type="java.lang.String">
<column name="damage_type" length="255"/>
</property>
<property name="exclusion" type="java.lang.String">
<column name="exclusion" length="255"/>
</property>
</joined-subclass>
</hibernate-mapping>

View File

@ -0,0 +1,36 @@
<?xml version="1.0"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class
name="org.hibernate.query.hhh12076.Extension"
table="claim_ext"
lazy="false">
<id name="id" type="java.lang.Long">
<column name="id"/>
<generator class="native"/>
</id>
<version name="version" unsaved-value="null" type="java.lang.Integer"/>
<property name="creationDate" type="timestamp" insert="false" update="false" generated="always">
<column name="creation_date"/>
</property>
<property name="modifiedDate" type="timestamp" insert="false" update="false" generated="always">
<column name="modified_date"/>
</property>
<property name="type" type="java.lang.String">
<column name="type" length="128" not-null="true"/>
</property>
<many-to-one name="claim" class="org.hibernate.query.hhh12076.Claim" fetch="select">
<column name="claim_id" not-null="true"/>
</many-to-one>
</class>
</hibernate-mapping>

View File

@ -0,0 +1,35 @@
<?xml version="1.0"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<joined-subclass
name="org.hibernate.query.hhh12076.GapAssessmentExtension"
extends="org.hibernate.query.hhh12076.SettlementExtension"
table="claim_settlement_ext_gap"
lazy="false">
<key>
<column name="extension_id" not-null="true"/>
</key>
<property name="eligibleAmount" type="java.lang.Double">
<column name="eligible_amount" not-null="true"/>
</property>
<property name="assessedAmount" type="java.lang.Double">
<column name="assessed_amount" not-null="true"/>
</property>
<property name="underinsuredAmount" type="java.lang.Double">
<column name="underinsured_amount" not-null="true"/>
</property>
<property name="insuredsObligation" type="java.lang.Double">
<column name="insureds_obligation_amount" not-null="true"/>
</property>
</joined-subclass>
</hibernate-mapping>

View File

@ -0,0 +1,64 @@
<?xml version="1.0"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class
name="org.hibernate.query.hhh12076.Settlement"
table="claim_settlement"
lazy="false">
<id name="id" type="java.lang.Long">
<column name="id"/>
<generator class="native"/>
</id>
<version name="version" unsaved-value="null" type="java.lang.Integer"/>
<property name="creationDate" type="timestamp" insert="false" update="false" generated="always">
<column name="creation_date"/>
</property>
<property name="modifiedDate" type="timestamp" insert="false" update="false" generated="always">
<column name="modified_date"/>
</property>
<property name="openDate" type="timestamp">
<column name="open_date" not-null="false"/>
</property>
<property name="allocateDate" type="timestamp">
<column name="allocate_date" not-null="false"/>
</property>
<property name="closeDate" type="timestamp">
<column name="close_date" not-null="false"/>
</property>
<property name="status">
<column name="status" not-null="true"/>
<type name="org.hibernate.type.EnumType">
<param name="type">12</param>
<param name="enumClass">org.hibernate.query.hhh12076.SettlementStatus</param>
</type>
</property>
<many-to-one
name="claim"
class="org.hibernate.query.hhh12076.Claim"
fetch="select">
<column name="claim_id" not-null="true"/>
</many-to-one>
<set
name="extensions"
inverse="true"
lazy="extra"
cascade="all"
batch-size="10"
order-by="order_index">
<key column="settlement_id" not-null="true"/>
<one-to-many class="org.hibernate.query.hhh12076.SettlementExtension"/>
</set>
</class>
</hibernate-mapping>

View File

@ -0,0 +1,40 @@
<?xml version="1.0"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class
name="org.hibernate.query.hhh12076.SettlementExtension"
table="claim_settlement_ext"
abstract="true"
lazy="false">
<id name="id" type="java.lang.Long">
<column name="id"/>
<generator class="native"/>
</id>
<version name="version" unsaved-value="null" type="java.lang.Integer"/>
<property name="creationDate" type="timestamp" insert="false" update="false" generated="always">
<column name="creation_date"/>
</property>
<property name="modifiedDate" type="timestamp" insert="false" update="false" generated="always">
<column name="modified_date"/>
</property>
<property name="orderIndex" type="integer">
<column name="order_index"/>
</property>
<many-to-one
name="settlement"
class="org.hibernate.query.hhh12076.Settlement"
fetch="select">
<column name="settlement_id" not-null="true"/>
</many-to-one>
</class>
</hibernate-mapping>

View File

@ -0,0 +1,25 @@
<?xml version="1.0"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<subclass
name="org.hibernate.query.hhh12076.SettlementTask"
extends="org.hibernate.query.hhh12076.Task"
discriminator-value="org.hibernate.query.hhh12076.SettlementTask"
lazy="false">
<many-to-one
name="linked"
class="org.hibernate.query.hhh12076.Settlement"
fetch="join">
<column name="linked_id" not-null="true"/>
</many-to-one>
</subclass>
</hibernate-mapping>

View File

@ -0,0 +1,91 @@
<?xml version="1.0"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class
name="org.hibernate.query.hhh12076.Task"
abstract="true"
table="wf_task"
lazy="false">
<id name="id" type="java.lang.Long">
<column name="id"/>
<generator class="native"/>
</id>
<discriminator force="false" insert="true" not-null="true">
<column name="type"/>
</discriminator>
<version name="version" unsaved-value="null" type="java.lang.Integer">
<column name="version"/>
</version>
<property lazy="false" name="creationDate" type="timestamp" insert="false" update="false" generated="always">
<column name="creation_date"/>
</property>
<property lazy="false" name="modifiedDate" type="timestamp" insert="false" update="false" generated="always">
<column name="modified_date"/>
</property>
<property name="startDate" type="java.util.Date">
<column name="start_date"/>
</property>
<property name="closeDate" type="java.util.Date">
<column name="close_date"/>
</property>
<property name="dueDate" type="java.util.Date">
<column name="due_date"/>
</property>
<property name="stateDueDate" type="java.util.Date">
<column name="state_due_date"/>
</property>
<property name="statusDueDate" type="java.util.Date">
<column name="status_due_date"/>
</property>
<property name="statusTransitionDate" type="java.util.Date">
<column name="status_transition_date"/>
</property>
<property name="stateTransitionDate" type="java.util.Date">
<column name="state_transition_date"/>
</property>
<many-to-one
name="status"
class="org.hibernate.query.hhh12076.TaskStatus"
fetch="select">
<column name="task_status" not-null="true"/>
</many-to-one>
<many-to-one
name="parent"
class="org.hibernate.query.hhh12076.Task"
fetch="select">
<column name="parent_id" not-null="false"/>
</many-to-one>
<set
name="children"
inverse="false"
lazy="extra"
cascade="all,delete-orphan"
batch-size="10">
<key column="parent_id"/>
<one-to-many class="org.hibernate.query.hhh12076.Task"/>
</set>
<set
name="linkedTasks"
table="wf_task_links"
lazy="true"
inverse="false"
mutable="false"
cascade="none">
<key column="task_id"/>
<many-to-many
class="org.hibernate.query.hhh12076.Task"
column="link_to_task_id"
/>
</set>
</class>
</hibernate-mapping>

View File

@ -0,0 +1,48 @@
<?xml version="1.0"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class
name="org.hibernate.query.hhh12076.TaskStatus"
table="wf_task_status"
lazy="false">
<cache usage="read-write"/>
<id name="id" type="java.lang.Long">
<column name="id"/>
<generator class="native"/>
</id>
<discriminator force="false" insert="true" not-null="true">
<column name="type"/>
</discriminator>
<version name="version" unsaved-value="null" type="java.lang.Integer">
<column name="version"/>
</version>
<property lazy="false" name="creationDate" type="timestamp" insert="false" update="false" generated="always">
<column name="creation_date"/>
</property>
<property lazy="false" name="modifiedDate" type="timestamp" insert="false" update="false" generated="always">
<column name="modified_date"/>
</property>
<property name="name" type="java.lang.String">
<column name="name" length="128" not-null="true"/>
</property>
<property name="displayName" type="java.lang.String">
<column name="display_name" length="128" not-null="true"/>
</property>
<property name="active" type="boolean">
<column name="active"/>
</property>
<property name="orderIndex" type="integer">
<column name="order_index"/>
</property>
</class>
</hibernate-mapping>