【发布时间】:2013-02-14 05:50:43
【问题描述】:
我的数据库中有一个简单的一对多关系。以下是对应的类:
class Department
{
int deptId;
int count; //This corresponds to the total number of Employees in a department
List<Employee> employees; //An employee belongs to only one department
}
class Employee
{
int employeeId;
Department dept;
}
为了保持count 更新,我在每个CUD 操作上设置count。是否有一种自动方法来更新部门每次添加/删除员工时的count? (注释/限制什么的?)
【问题讨论】:
标签: java hibernate orm count one-to-many