I am trying to model 1:N (Person & Address) relationship using a junction table (Person_Address).
1.Person (personId PK)
2.Address (addressId PK)
3.PersonAddress ( personId, addressId composite PK, personId FK r开发者_如何学Goeferences Person, addressid FK references Address )
@Entity
public class Person {
@OneToMany
@JoinTable(
name="PersonAddress",
joinColumns = @JoinColumn( name="personId"),
inverseJoinColumns = @JoinColumn( name="addressId")
)
public Set<Address> getAddresses() {...} ...
}
I encounter following error. Not able to find any solution.
Caused by: org.hibernate.MappingException: Could not determine type for: com.realestate.details.Address, at table: Person, for columns:
[org.hibernate.mapping.Column(address)] at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:269) at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253) at org.hibernate.mapping.Property.isValid(Property.java:185) at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:440) at org.hibernate.mapping.RootClass.validate(RootClass.java:192) at org.hibernate.cfg.Configuration.validate(Configuration.java:1108) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1293)
- Make sure you don't have
@Column private Address address
in yourPerson
entity - Make sure
Address
is mapped as@javax.persistence.Entity
精彩评论