2013-02-28 29 views
1

嵌入式我有以下的模型類:在DataNucleus將

@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 
以下DataNucleus將性能

在視圖(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。

任何想法爲什麼這個以及如何修復它?

回答

1

添加

@Basic(fetch=FetchType.EAGER) 

private B b; 

這將使乙預先抓取並使其正常拆卸。

您可以嘗試使用抓取組來指定何時應該抓取的內容。