简体   繁体   中英

Using @FetchGroup with eclipseLink

I have tried to get source running as explained in http://eclipse.org/eclipselink/documentation/2.4/jpa/extensions/a_fetchgroup.htm

@FetchGroup(name="names", 
    attributes={ 
         @FetchAttribute(name="firstName"),
         @FetchAttribute(name="lastName")
}) 


TypedQuery query = em.createQuery("SELECT e FROM Employee e", Employee.class);    
query.setHint(QueryHints.FETCH_GROUP_NAME, "names"); 

Sadly it ends up with "Needs to implement FetchGroupTracker".

I don't know if it is really the case or I'm missing something. Does anybody know where I can find a sample for it?

You must set up byte code weaving/enhancement for this to work automatically, otherwise your entities will need to implement the FetchGroupTracker class so that the fetch group attributes can be put into and used by your entity. See https://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Performance/Weaving

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM