Dozer:Hibernate PersistentMap未映射到java.util.HashMap
我有一个带Hibernate注释的实体,带有一个字段:Dozer:Hibernate PersistentMap未映射到java.util.HashMap,hibernate,hashmap,dozer,Hibernate,Hashmap,Dozer,我有一个带Hibernate注释的实体,带有一个字段: @OneToMany(mappedBy="templateInstance", fetch = FetchType.EAGER) @MapKey(name = "attributeName") private Map<String, Component> components; private Map<String, ComponentDto> components; @OneToMany(mappedB
@OneToMany(mappedBy="templateInstance", fetch = FetchType.EAGER)
@MapKey(name = "attributeName")
private Map<String, Component> components;
private Map<String, ComponentDto> components;
@OneToMany(mappedBy=“templateInstance”,fetch=FetchType.EAGER)
@映射键(name=“attributeName”)
私有地图组件;
Hibernate将其制作成一个PersistentMap。
然后我想让Dozer将其映射到具有这样一个字段的对象:
@OneToMany(mappedBy="templateInstance", fetch = FetchType.EAGER)
@MapKey(name = "attributeName")
private Map<String, Component> components;
private Map<String, ComponentDto> components;
私有地图组件;
在经历LazyInitializationExceptions和一些调试之后,我发现这不是一个关闭的Hibernate会话的问题,但是Dozer尝试不映射到HashMap,而是映射到PersistentMap!因此,当Dozer访问目标映射时,PersistentMap抛出异常,因为它当然没有会话
所以,我认为Dozer的预期行为是映射到HashMap。现在的问题是:我是否做错了什么,或者Dozer,以及如何让Dozer将PersistentMap映射到普通Java标准映射
我以前使用列表时没有问题。还有其他人使用Dozer映射Hibernate PersistentMap吗
问候,,
康苏米尔我自己找到了解决办法。DTO中的components字段必须如下所示:
HashMap<String, Component> components = new HashMap<String, Component>;
有关该问题的更多信息,请参阅位于的推土机论坛