JPA One to Many using JoinTable Error
- by user553015
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 references 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)