我有一个Parent
实体,它将Child
实体作为地图中的值引用。地图中的关键是枚举(请参阅下面的简单代码)。不幸的是,使用带有表名的@AuditJoinTable
不会创建预期的“parent_children_aud”表。
是否支持审核地图参考?或者有什么我做错了吗?
使用Hibernate 3.6.0。
家长班:
@Audited
public class Parent {
private Long id;
private Integer version;
private Map<MyEnum, Child> mappedChildren;
protected Parent() {}
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getVersion() {
return version;
}
public void setVersion(Integer version) {
this.version = version;
}
@AuditJoinTable(name = "parent_children_aud")
public Map<MyEnum, Child> getMappedChildren() {
return this.mappedChildren;
}
public void setMappedChildren(Map<MyEnum, TemplateStage> mappedChildren) {
this.mappedChildren = mappedChildren;
}
}
儿童班:
@Audited
public class Child {
private Long id;
protected Child() {}
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getVersion() {
return version;
}
public void setVersion(Integer version) {
this.version = version;
}
}
MyEnum:
public enum MyEnum { AAA, BBB, CCC; }
的hbm.xml:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
-//Hibernate/Hibernate Mapping DTD 3.0//EN
http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd>
<hibernate-mapping>
<class name="Parent" table="parents">
<cache usage="read-write"/>
<id name="id" column="id">
<generator class="native"/>
</id>
<version name="version" unsaved-value="negative"/>
<map name="mappedChildren" cascade="all-delete-orphan" lazy="true">
<cache usage="read-write"/>
<key column="parent_id"/>
<map-key type="MyEnum"/>
<one-to-many class="Child"/>
</map>
</class>
<class name="Child" table="children">
<cache usage="read-write"/>
<id name="id">
<generator class="native"/>
</id>
<version name="version" unsaved-value="negative"/>
</class>
</hibernate-mapping>