我们下面有两个 POJO
public class Notification extends AbstractDomainObject{
private String name;
private List<User> users;
//setter getter
}
public class User extends AbstractDomainObject{
private String userName;
//getter setter
}
public class AbstractDomainObject{
private Long id;
//getter setter
}
我的休眠映射是
<hibernate-mapping >
<class name="User" table="user">
<id name="id" type="long" column="id">
<generator class="native" />
</id>
<property name="userName" type="string">
<column name="user_name" />
</property>
</class>
<class name="Notification " table="notification">
<id name="id" type="long" column="id">
<generator class="native" />
</id>
<property name="name" type="string">
<column name="name" />
</property>
<list name="users" table="notification_for" cascade="all-delete-orphan" >
<key column="notification_id" />
<list-index column="idx" />
<one-to-many class="User" />
</list>
</class>
</hibernate-mapping>
我希望hibernate 应该notification_for
为用户和通知的映射维护一个单独的表()。
hibernate 正在做的是维护idx
和notification_id
在user
表中。我希望hibernate应该维护一个notification_for
带有列的表user_id
,notification_id
我应该怎么做。有什么建议吗?