I have a very simple issue, and I’m not sure if it’s a bug in hibernate, or an issue with JPA 2.0.
I have a simple @Entity
@Entity
public class LegacyClearanceNodeMapping {
@Id
@ManyToOne
@JoinColumn(name="nid")
private LegacyNode clearanceNode;
@ManyToOne
@JoinColumn(name="rentable_nid")
private LegacyNode rentableNode;
@Column
private Integer quality;
..snip..
}
Essentially, it’s a Many-to-many map class, but it has meta-data on the association, so I can’t treat it that way.
When I try to startup hibernate though, I get the follwoing error:
org.hibernate.MappingException: Could not determine type for:
com.***.inventory.model.clearance.LegacyNode, at table: LegacyClearanceNodeMapping, for columns: [org.hibernate.mapping.Column(clearanceNode)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:292)
at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:175)
at org.hibernate.cfg.Configuration.iterateGenerators(Configuration.java:743)
at org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:854)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:128)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:91)
I can only suspect that Hibernate doesn’t like the PK being a fk, but I can’t change the schema.
Any known resolutions?
Thanks
You must have a basic property mapped as ID, and a ManyToOne mapped on the same column, and using the
@MapsIdannotation.