【发布时间】:2014-09-22 12:05:15
【问题描述】:
我目前正在使用 Spring-MVC 和休眠。我在数据库中有 2 个表,table1 和 table2。 Table1 与 table2 具有 oneToMany 关系。当我使用查询运行应用程序以从 Table1 中删除一行及其从 Table2 中的子项时,我收到一条错误消息,指出关系 Table1_table2 不存在。
Code :
@Table(name="table1")
class user{
@OneToMany
public Set<Accounts> accounts;
//Remove method
Query query = session.createQuery("From User as u LEFT JOIN FETCH u.accounts WHERE u.id="+id)
//then I use a for loop to go through the Accoutns and remove the accounts.
}
@Table(name="Table2")
class accounts{
@manyToOne
public User user;
}
【问题讨论】:
标签: spring hibernate postgresql spring-mvc