cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Jarrel <garyjar...@gmail.com>
Subject Re: Testing for Pagination
Date Wed, 30 Jun 2010 04:51:45 GMT
On Wed, Jun 30, 2010 at 1:44 PM, Aristedes Maniatis <ari@maniatis.org> wrote:
>
> If that is happening, then that might be a bug. Could you put logging in
> there to identify exactly when you see the SQL query inflating the record?
> Does it happen right after getPersistenceState()?
>

I've changed the test case to:

List<Role> results = getDataContext().performQuery(s);

assertEquals(5, results.size());

Role r0 = results.get(0);
Role r1 = results.get(1);
assertEquals(PersistenceState.COMMITTED, r0.getPersistenceState());
assertEquals(PersistenceState.COMMITTED, r1.getPersistenceState());

Role r4 = results.get(4);
assertEquals(PersistenceState.HOLLOW, r4.getPersistenceState());

Stepping though the code with a debugger the following happens:

List<Role> results = getDataContext().performQuery(s);

Causes:

SELECT t0.role_id FROM role t0

Role r0 = results.get(0);

Causes

SELECT t0.name, t0.active, t0.role_id FROM role t0 WHERE (t0.role_id =
?) OR (t0.role_id = ?) [bind: 1->role_id:1, 2->role_id:2]

As you said the whole page is inflated rather than a single object

Nothing in the log until:

Role r4 = results.get(4);

Which causes:

SELECT t0.name, t0.active, t0.role_id FROM role t0 WHERE t0.role_id =
? [bind: 1->role_id:5]

Hence once this executes the test fails as r4 is not hollow!

Gary

Mime
View raw message