We are moving from openJPA to Hibernate. All latest GA jars from hibernate. We had a set of classes which were working with openJPA. Now they are not working. It always throws an exception saying " No column for logical name CODE in GGG_CASE_CODE". We are unable to find the issue. Can someone please help.
We have a CaseCode entity which is configuration data discriminated on CODE_TYPE. See CaseCategory and CaseStatus entities.
BaseInvestigation is another entity which uses these entities.
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
@Entity
@Table(name = "GGG_CASE_CODE")
@DiscriminatorColumn(name = "CODE_TYPE")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@IdClass(CaseCodePK.class)
public class CaseCode {
private static final long serialVersionUID = 7260885509190214084L;
private String codeDescription;
private Character active;
private Character changeable;
private String caseType;
private String caseCode;
private String tenantCode;
private String productCode;
/*
* @Transient public IKey getKey() { return caseCodePK; }
*/
@Id
@Column(name="CODE")
public String getCaseCode() {
return caseCode;
}
public void setCaseCode(String caseCode) {
this.caseCode = caseCode;
}
@Id
@Column(name="PRODUCT_CODE")
public String getProductCode() {
return productCode;
}
public void setProductCode(String productCode) {
this.productCode = productCode;
}
@Id
@Column(name="TENANT_CODE")
public String getTenantCode() {
return tenantCode;
}
public void setTenantCode(String tenantCode) {
this.tenantCode = tenantCode;
}
@Basic
@Column(name = "DESCRIPTION")
public String getCodeDescription() {
return codeDescription;
}
public void setCodeDescription(String codeDescription) {
this.codeDescription = codeDescription;
}
@Basic
@Column(name = "ACTIVE")
public Character getActive() {
return active;
}
public void setActive(Character isActive) {
this.active = isActive;
}
@Basic
@Column(name = "UNCHANGEABLE")
public Character getChangeable() {
return changeable;
}
public void setChangeable(Character isChangeable) {
this.changeable = isChangeable;
}
@Basic
@Column(name = "CODE_TYPE")
public String getCaseType() {
return caseType;
}
public void setCaseType(String caseCode) {
this.caseType = caseCode;
}
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
import static org.apache.commons.lang.StringUtils.isEmpty;
import javax.persistence.Column;
public class CaseCodePK implements IKey {
private static final long serialVersionUID = -2482325480214656703L;
private static final String GET_CASE_CODE_PK_MSG = "CaseCodePK constructor requires valid parameter values.";
private String caseCode;
private String tenantCode;
private String productCode;
public CaseCodePK(final String caseCode, final String tenantCode,
final String productCode) {
if (isEmpty(caseCode) || isEmpty(tenantCode) || isEmpty(productCode)) {
throw new IllegalArgumentException(GET_CASE_CODE_PK_MSG);
}
this.caseCode = caseCode;
this.tenantCode = tenantCode;
this.productCode = productCode;
}
public CaseCodePK() {
super();
}
public String getCaseCode() {
return caseCode;
}
public void setCaseCode(String caseCode) {
this.caseCode = caseCode;
}
public String getProductCode() {
return productCode;
}
public void setProductCode(String productCode) {
this.productCode = productCode;
}
public String getTenantCode() {
return tenantCode;
}
public void setTenantCode(String tenantCode) {
this.tenantCode = tenantCode;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof CaseCodePK)) {
return false;
}
CaseCodePK caseCodePK = (CaseCodePK) o;
return caseCodePK.getCaseCode().equals(caseCode)
&& caseCodePK.getProductCode().equals(productCode)
&& caseCodePK.getTenantCode().equals(tenantCode);
}
@Override
public int hashCode() {
return caseCode.hashCode() + 17 * productCode.hashCode() + 31
* tenantCode.hashCode();
}
@Override
public String toString() {
return caseCode + " - " + productCode + " -" + tenantCode;
}
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
@Entity(name = "CaseCategory")
@DiscriminatorValue("CC")
public class CaseCategory extends CaseCode {
private static final long serialVersionUID = -1110397356280112003L;
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
@Entity(name = "CaseStatus")
@DiscriminatorValue("CS")
public class CaseStatus extends CaseCode {
private static final long serialVersionUID = 6818260712290539908L;
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@Entity(name = "BaseInvestigation")
@Table(name = "FFF_CASE")
@DiscriminatorColumn(name = "SUB_TYPE")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class BaseInvestigation extends AbstractEntity {
private static final long serialVersionUID = -7192143041870463648L;
private String targetID;
private TargetType targetType;
private Date openDate;
private Date lastActivityDate;
private CaseStatus status;
private CaseCategory category;
private String targetName;
private String parentID;
private String flaggedProvider;
private String casePotential;
private String subType;
private BaseInvestigationPK investigationPK;
public IKey getKey() {
return investigationPK;
}
@Basic
@Column(name = "CASE_POTENTIAL")
public String getCasePotential() {
return casePotential;
}
public void setCasePotential(String casePotential) {
this.casePotential = casePotential;
}
@ManyToOne(fetch = FetchType.EAGER, targetEntity = CaseCategory.class, cascade = {
CascadeType.MERGE, CascadeType.REFRESH })
@JoinColumns( {
@JoinColumn(name = "CATEGORY", referencedColumnName = "CODE", nullable = false),
@JoinColumn(name = "PRODUCT_CODE", nullable = false),
@JoinColumn(name = "TENANT_CODE", nullable = false) })
public CaseCategory getCategory() {
return category;
}
public void setCategory(CaseCategory category) {
this.category = category;
}
@Basic
@Column(name = "FLAGGED_PROV")
public String getFlaggedProvider() {
return flaggedProvider;
}
public void setFlaggedProvider(String flaggedProvider) {
this.flaggedProvider = flaggedProvider;
}
@Basic
@Column(name = "LAST_ACT_DT")
public Date getLastActivityDate() {
return lastActivityDate;
}
public void setLastActivityDate(Date lastActivityDate) {
this.lastActivityDate = lastActivityDate;
}
@Basic
@Column(name = "OPEN_DT")
public Date getOpenDate() {
return openDate;
}
public void setOpenDate(Date openDate) {
this.openDate = openDate;
}
@Basic
@Column(name = "PARENT_ID")
public String getParentID() {
return parentID;
}
public void setParentID(String parentID) {
this.parentID = parentID;
}
@ManyToOne(fetch = FetchType.EAGER, targetEntity = CaseStatus.class, cascade = {
CascadeType.MERGE, CascadeType.REFRESH })
@JoinColumns( {
@JoinColumn(name = "STATUS", referencedColumnName = "CODE", nullable = false),
@JoinColumn(name = "PRODUCT_CODE", nullable = false),
@JoinColumn(name = "TENANT_CODE", nullable = false) })
public CaseStatus getStatus() {
return status;
}
public void setStatus(CaseStatus status) {
this.status = status;
}
@Basic
@Column(name = "TARG_ID")
public String getTargetID() {
return targetID;
}
public void setTargetID(String targetID) {
this.targetID = targetID;
}
@Basic
@Column(name = "TARG_NAME")
public String getTargetName() {
return targetName;
}
public void setTargetName(String targetName) {
this.targetName = targetName;
}
@Column(name = "TARG_TYPE")
@Enumerated(EnumType.STRING)
public TargetType getTargetType() {
return targetType;
}
public void setTargetType(TargetType targetType) {
this.targetType = targetType;
}
@EmbeddedId
public BaseInvestigationPK getInvestigationPK() {
return investigationPK;
}
public void setInvestigationPK(BaseInvestigationPK investigationPK) {
this.investigationPK = investigationPK;
}
@Basic
@Column(name = "SUB_TYPE")
public String getSubType() {
return subType;
}
public void setSubType(String subType) {
this.subType = subType;
}
}
|