I am using eclipselink 2.6.3 and have the following code:
public Temp getTemp() {
EntityManager em=emf.createEntityManager();
String queryString="SELECT a FROM Temp a";
EntityGraph<Temp> eg = em.createEntityGraph(Temp.class);
eg.addAttributeNodes("id");
Query query = em.createQuery(queryString);
query.setHint("javax.persistence.fetchgraph", eg);
List<Temp> items=query.getResultList();
em.close();
return items.get(0);
}
public void temp(){
Temp temp=getTemp();
System.out.println("id:"+temp.getId());
System.out.println("name:"+temp.getName());
}
Situation 1:
When weaving is static ( <property name="eclipselink.weaving" value="static"/>+ de.empulse.eclipselink weaving plugin), and we do temp.getName (), an onemore SQL query is executed and the necessary data is loaded. Despite the fact that we closed the entity manager. I was expecting to get an exception in temp.getName ().
Situation 2:
However, when weaving is dynamic ( <property name="eclipselink.weaving" value="true"/>), I get an exception:
java.lang.ClassNotFoundException: org.eclipse.persistence.internal.jpa.EntityManagerImpl not found by com.temp [57]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1574)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2018)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at com.temp.Temp._persistence_checkFetched(Temp2.java)
at com.temp.Temp._persistence_get_name(Temp2.java)
at com.temp.Temp.getName(Temp.java:44)
How to explain this difference? This is mistake?
source
share