FetchGroup for relation attributes [message #1346759] |
Sat, 10 May 2014 20:39 |
jason zhang Messages: 31 Registered: July 2009 |
Member |
|
|
Hi, All I am using FetchGroup feature in EclipseLink 2.5.1
I am using the Expression Framework and dynamic entities. My code is like this
ReadAllQuery readAllQuery=...
readAllQuery.setCacheUsage(ObjectLevelReadQuery.DoNotCheckCache);
readAllQuery.dontMaintainCache();
FetchGroup fetchGroup=new FetchGroup();
fetchGroup.addAttribute("Name");
fetchGroup.addAttribute("doomroom.name");
readAllQuery.setFetchGroup(fetchGroup);
results=session.executeQuery(readAllQuery);
Here is the sql executed by eclipselink
Quote:
1. [EL Fine]: sql: 2014-05-10 12:15:20.419--ServerSession(14983258)--Connection(2105963)--Thread(Thread[main,5,main])--SELECT ID, NAME, FXVERSION, DOOMROOM_ID FROM MSTUDENT WHERE NOT ((DOOMROOM_ID IS NULL))
2. [EL Fine]: sql: 2014-05-10 12:15:20.437--ServerSession(14983258)--Connection(2105963)--Thread(Thread[main,5,main])--SELECT ID, FXVERSION, NAME FROM MDOOMROOM WHERE (ID = ?)
bind => [504]
3. [EL Fine]: sql: 2014-05-10 12:15:20.451--ServerSession(14983258)--Connection(2105963)--Thread(Thread[main,5,main])--SELECT ID, FXVERSION, NAME FROM MDOOMROOM WHERE (ID = ?)
bind => [502]
Here are something I observed.
1. I do not have sql line 2 and 3 in the log above If I do not use em.getEntityManagerFactory().getCache().evictAll() before query. The line 2 and line 3 are sql to load related entities(doomroom). I thought cache is not checked since I have readAllQuery.setCacheUsage(ObjectLevelReadQuery.DoNotCheckCache); How can I ask this particular query not checking cache.
2. Not matter whether I evict all object from cache or not, the related entities always have all attributes loaded. The sql indicated only id, version and specified property (name) is loaded, but returned object has every properties loaded. Could it possible that the returned object is not the one from database, but the one in cache?
3. Can I use EntityGraph with Expression framework?
Help is really appreciated.
thanks
-jason
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03344 seconds