JPA一对多使用JoinTable错误

时间:2010-12-24 15:16:16

标签: jpa

我正在尝试使用联结表(Person_Address)建模1:N(人员和地址)关系。

1.Person(personId PK)

2.Address(addressId PK)

3.PersonAddress(     personId,addressId复合PK,     personId FK引用人,     addressid FK引用地址   )

@Entity 
public class Person {  

@OneToMany   
@JoinTable(
    name="PersonAddress", 
    joinColumns = @JoinColumn( name="personId"),     
    inverseJoinColumns = @JoinColumn( name="addressId")    
)   

public Set<Address> getAddresses() {...}  ... 
} 

我遇到以下错误。无法找到任何解决方案。

按引起:org.hibernate.MappingException:无法确定类型:com.realestate.details.Address,在表:人,对于列:

[org.hibernate.mapping.Column(地址)]在org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:269)在org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)在org.hibernate.mapping.Property.isValid(Property.java:185)在org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:440)在org.hibernate.mapping.RootClass.validate(RootClass.java:192)在org.hibernate.cfg.Configuration.validate(Configuration.java:1108)在org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1293)

1 个答案:

答案 0 :(得分:1)

  1. 确保您的@Column private Address address实体
  2. 中没有Person
  3. 确保Address映射为@javax.persistence.Entity