JPA One to Many using JoinTable Error

Posted by user553015 on Stack Overflow See other posts from Stack Overflow or by user553015
Published on 2010-12-24T15:16:16Z Indexed on 2010/12/24 15:54 UTC
Read the original article Hit count: 266

Filed under:

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)

© Stack Overflow or respective owner

Related posts about jpa