HI!
i have 2 tables - House and HouseContact:
DB: postgreSQL
table house: columns: id(bigint), name (varchar), address(varchar)
table house_contact: columns: id(bigint), name (varchar), fk_house_id (bigint) - foreign key to House table
Code:
@Entity @Table(name="house")
public class House extends BaseObject {
private Long id;
private String name = null;
private String address = null;
public House() {}
@OneToMany (fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(name = "fk_house_id")
private List<HouseContact> houseContacts;
public void addHouseContact(HouseContact houseContact) {
if (this.houseContacts == null) {
houseContacts = new ArrayList<HouseContact>();
}
this.houseContacts.add(houseContact);
houseContact.setHouse(this);
}
public List<HouseContact> getHouseContacts() {
return houseContacts;
}
public void setHouseContacts(List<HouseContact> houseContacts) {
this.houseContacts = houseContacts;
}
......
}
@Entity @Table(name="house_contact")
public class HouseContact extends BaseObject {
private Long id;
private String name = null;
public HouseContact() {}
@ManyToOne (fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(name = "fk_house_id", nullable = false)
private House house;
public House getHouse() {
return house;
}
public void setHouse(House house) {
this.house= house;
}
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seq_house_contact")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
.....
}
a I have this error message:
Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for: java.util.List, for columns: [org.hibernate.mapping.Column(houseContacts)]
please, where is the problem ?
thanks!
Ivan