I have a one-to-one relationship, but hibernatetool complains when creating the schema. Here is an example that shows the problem:
@Entity public class Person { @Id public int id; @OneToOne public OtherInfo otherInfo; rest of attributes ... }
A person has a one-to-one relationship with OtherInfo:
@Entity public class OtherInfo { @Id @OneToOne(mappedBy="otherInfo") public Person person; rest of attributes ... }
The person belongs to the OtherInfo side. OtherInfo is its own side, so a person uses mappedBy to specify the name of the "otherInfo" attribute in Person.
I get the following error when using hibernatetool to create a database schema:
org.hibernate.MappingException: Could not determine type for: Person, at table: OtherInfo, for columns: [org.hibernate.mapping.Column(person)] 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) ...
Any idea why? Am I doing something wrong or is it a Hibernate error?
java hibernate jpa
Steve Kuo Apr 24 '09 at 21:48 2009-04-24 21:48
source share