映射异常:调用目标异常
我这里有一个小问题,希望有人可以帮助我。
我想做一个从对象到整数的映射。该对象被标记为 Fetchtype.Lazy。
当我进行映射时,我收到以下错误消息:
11:31:46,569 ERROR MappingProcessor:253 - Field mapping error -->
MapId: null
Type: null
Source parent class: ClassA
Source field name: MyObjectProperty
Source field type: null
Source field value: null
Dest parent class: ClassB
Dest field name: myIntegerProperty
Dest field type: java.lang.Integer
org.dozer.MappingException: java.lang.reflect.InvocationTargetException
at org.dozer.util.MappingUtils.throwMappingException(MappingUtils.java:88)
at org.dozer.util.ReflectionUtils.invoke(ReflectionUtils.java:258)
at org.dozer.propertydescriptor.GetterSetterPropertyDescriptor.invokeReadMethod(GetterSetterPropertyDescriptor.java:234)
at org.dozer.propertydescriptor.GetterSetterPropertyDescriptor.getPropertyValue(GetterSetterPropertyDescriptor.java:68)
at org.dozer.fieldmap.FieldMap.getSrcFieldValue(FieldMap.java:82)
InnerException:
Caused by: java.lang.IllegalStateException: Attempt to access an unloaded field of detached instance
我在 dozer xml 文件中创建了一个自定义转换器,但从未调用该转换器。我猜想应用程序在到达此转换器之前会遇到问题。
有趣的是,我可以反过来成功映射字段,即整数到对象。
我很感激任何想法,如果您需要更多信息,请给我留言。
谢谢大家。
I have a small problem here and hope that someone can help me out.
I wanna do a mapping from Object to Integer. The Object is marked as Fetchtype.Lazy.
When I do the mapping I get the following error message:
11:31:46,569 ERROR MappingProcessor:253 - Field mapping error -->
MapId: null
Type: null
Source parent class: ClassA
Source field name: MyObjectProperty
Source field type: null
Source field value: null
Dest parent class: ClassB
Dest field name: myIntegerProperty
Dest field type: java.lang.Integer
org.dozer.MappingException: java.lang.reflect.InvocationTargetException
at org.dozer.util.MappingUtils.throwMappingException(MappingUtils.java:88)
at org.dozer.util.ReflectionUtils.invoke(ReflectionUtils.java:258)
at org.dozer.propertydescriptor.GetterSetterPropertyDescriptor.invokeReadMethod(GetterSetterPropertyDescriptor.java:234)
at org.dozer.propertydescriptor.GetterSetterPropertyDescriptor.getPropertyValue(GetterSetterPropertyDescriptor.java:68)
at org.dozer.fieldmap.FieldMap.getSrcFieldValue(FieldMap.java:82)
InnerException:
Caused by: java.lang.IllegalStateException: Attempt to access an unloaded field of detached instance
I created a custom converter in dozer xml file but the converter is never called. I guess the application gets a problem before reaching this converter.
Funny thing is I can Map the fields successfully the other way around, so Integer to Object.
I appreciate any ideas, if you need further information please give me a word.
Thx to all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果这是 Hibernate,我会认为在数据 bean 绑定到的会话之外访问了延迟加载的字段。
我建议加载实体并将其映射到同一事务中可以解决问题。我当然不确定:)
If this were Hibernate I'd think a lazily loaded field were accessed outside of the Session the data bean is bound to.
I suggest loading the entity and mapping it in the same transaction would solve the problem. I don't know that for sure of course :)