In a Spring MVC application using hibernate and JPA, I am trying to set up a mapping for an object whose underlying data table has a two-column primary key. How can I change my code below to make it work?
I created an EmbeddedId called conceptPK, but I get the following error message:
Caused by: org.hibernate.MappingException:
Unable to find column with logical name: conceptPK
in org.hibernate.mapping.Table(sct2_concept) and its related supertables and secondary tables
In the entity class, I configured the primary key with the following code:
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name="id", column=@Column(name="id")),
@AttributeOverride(name="effectiveTime", column=@Column(name="effectiveTime"))
})
private ConceptPK conceptPK;
The nested ConceptPK class is as follows:
@Embeddable
class ConceptPK implements Serializable {
@Column(name="id", nullable=false)
protected BigInteger id;
@Column(name="effectiveTime", nullable=false)
@Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
private DateTime effectiveTime;
public DateTime getEffectiveTime(){return effectiveTime;}
public void setEffectiveTime(DateTime ad){effectiveTime=ad;}
public void setId(BigInteger id) {this.id = id;}
public BigInteger getId() {return id;}
}
To make reading easier, I uploaded the full code and the full stack trace to the file sharing site, rather than creating an overly long publication here.
You can read the full code for the class abovethe file sharing site by clicking on this link .
a second class, .
a third class, .
SQL code, .
.