-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: openJPA to Hibernate No logical name for column CODE
PostPosted: Fri Oct 03, 2008 12:44 am 
Newbie

Joined: Thu Oct 02, 2008 5:43 am
Posts: 1
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;
}

}


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 04, 2008 6:41 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

could you please also post the stack trace and maybe the content of the log file?

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 09, 2008 12:07 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
There is a little bug (but hard to solve) in Hibernate.
You need to define the @Column annotations on CaseCodePK as well.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Unable to find column with logical name
PostPosted: Fri Dec 26, 2008 8:23 pm 
Newbie

Joined: Fri Dec 26, 2008 8:10 pm
Posts: 1
Location: Netherlands
Thanks for this solution. It really helped me out.

Regards,
Roel

To help someone Googling for the message (like I was)....
The exception I got for hours was:
Unable to find column with logical name: <column_name> in org.hibernate.mapping.Table(<table_name>) and its related supertables and secondary tables


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.