Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] FetchGroups and eclipselink.weaving.eager=true

Hi Frank,

Could you please log a bug.

Thanks a lot,

Andrei

On 8/12/2010 12:41 PM, Frank Schwarz wrote:
Hi,

I stumbled upon a little oddity that I would like to understand:

Lets say there are two classes Employee and Address with an unidirectional
one-to-one-relationship from employee to address. The address property will
be eagerly loaded as default.

If I then define a FetchGroup as:

FetchGroup empGr = new FetchGroup();
empGr.addAttribute("name");

to only fetch the "id" and "name" attribute, I observe to following behavior
with eclipselink.weaving.eager=true:

FetchGroup empGr = new FetchGroup();
empGr.addAttribute("name");
TypedQuery<Employee> query = em.createQuery("select e from Employee e where
e.id = 6", Employee.class);
query.setHint(QueryHints.FETCH_GROUP, empGr);
List<Employee> results = query.getResultList();

With the operation 'getResultList()' there are 3 SQL statements logged:

SELECT ID, NAME FROM EMPLOYEE WHERE (ID = ?)
SELECT ID, STARTDATE, NAME, SALARY, ADDRESS_ID FROM EMPLOYEE WHERE (ID = ?)
SELECT ID, ZIP, STREET, STATE, CITY FROM ADDRESS WHERE (ID = ?)

I actually was expecting only the first one. If I switch off
"eclipselink.weaving.eager" then everything works as intended.

My question now: Is this behavior correct and how could it be possibly
explained?

Thank you for your help.
Frank


Back to the top