我有一个Parent
实体,它将一个Child
实体作为地图中的一个值。地图中的键是一个枚举(见下面的简单代码)。不幸的是,使用@AuditJoinTable
表名不会创建预期的“parent_children_aud”表。
是否支持对地图引用的审核?还是我做错了什么?
使用休眠 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;
}
}
我的枚举:
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>