我有以下模型类:
@Entity
public class A {
private B b;
}
@Embeddable
public class B {
...
}
我正在使用 Spring MVC,控制器使用 @Transactional 注释,并且我指定了以下数据核属性(以及其他属性)
datanucleus.detachAllOnCommit=true
datanucleus.detachAllOnClose=true
datanucleus.detachState=all
datanucleus.copyOnAttach=true
datanucleus.attachSameDatastore=true
datanucleus.maxFetchDepth=2
在视图(JSP)中,当事务应该结束并且对象分离时,如果我尝试访问${a.b.whatever}
我会收到此错误
javax.jdo.JDODetachedFieldAccessException: You have just attempted to access field "b" yet this field was not detached when you detached the object. Either dont access this field, or detach it when detaching the object.
A.jdoGetb(A.java)
A.getB(A.java)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
org.apache.el.parser.AstValue.getValue(AstValue.java:123)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:935)
...
我将 DataNucleus 3.1.3 与 MySQL 一起使用。
知道为什么会这样,我该如何解决?