Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo]lazy collection pagination
[Teneo]lazy collection pagination [message #82722] Thu, 10 May 2007 09:08 Go to next message
Anthony Lee is currently offline Anthony LeeFriend
Messages: 114
Registered: July 2009
Senior Member
Hi,



Since it is no effect to setMaxResult for the query 'select parent fetch
join parent.children ...' , I wonder if there is one way to let lazy
collection only return certain numbers of itetm.

I try to use parent.getChildren().iterator(),but once iterator.hasNext
() or iterator.next() get called, all the item are loaded.

Any workaround idea ?

Thanks in advance!

Anthony Lee
Re: [Teneo]lazy collection pagination [message #82723 is a reply to message #82722] Thu, 10 May 2007 09:18 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi,
A quick google search turned up these two pages:
http://www.hibernate.org/118.html#A8
http://www.javalobby.org/java/forums/t43955.html

but, I am not sure if it works as Teneo implements its own persistable elist....

then Hibernate also has the lazy="extra" attribute on a list-mapping but this is not implemented yet
with Teneo (there is a bugzilla for this but I did not have time yet).

gr. Martin

Anthony wrote:
> Hi,
>
>
>
> Since it is no effect to setMaxResult for the query 'select parent fetch
> join parent.children ...' , I wonder if there is one way to let lazy
> collection only return certain numbers of itetm.
>
> I try to use parent.getChildren().iterator(),but once iterator.hasNext
> () or iterator.next() get called, all the item are loaded.
>
> Any workaround idea ?
>
> Thanks in advance!
>
> Anthony Lee


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo]lazy collection pagination [message #82725 is a reply to message #82723] Thu, 10 May 2007 09:58 Go to previous messageGo to next message
Anthony Lee is currently offline Anthony LeeFriend
Messages: 114
Registered: July 2009
Senior Member
Hi,
Thank you for your tips.

According to http://www.javalobby.org/java/forums/t43955.html,
============================================================ ==========
4 . At 12:46 PM on Aug 23, 2005, R.J. Lorimer wrote:
Reply
Re: Hibernate: Filter Collections
Sandro,

That's the beauty of filtered collections, when they are lazy, they don't
generate 2 select statements.

When you call owner.getPets() it simply gives you the
'PersistentCollection' from Hibernate, which doesn't actually invoke the
SQL until you use it (say via owner.getPets().iterator().next()). Because
of that, you can add a filter to it which is simply a way of adding
additional criteria to the SQL that will be invoked to initialize the
collection.
============================================================ ============

I create a method just like this:

public static List getPagingResult(Object collection, int beginIndex, int
pageSize){
final Query pagingFilter = sessionController.getSession().createFilter
(collection,"");
pagingFilter.setFirstResult(begin);
pagingFilter.setMaxResult(pageSize);
List pageContent = pagingFilter.list();
}

and then I try to use the lazy collection as the first parameter to call
this method.

But I got an exception :

org.hibernater.QueryException:The collection was unreferenced

In http://www.hibernate.org/117.html#A11, it says the reason is:

Collection filters are for filtering persistent collections, not query
results.

But it is persistent collection.

?

Anthony

















Martin Taal <mtaal@elver.org> wrote in
news:f1uo0b$com$1@build.eclipse.org:

> Hi,
> A quick google search turned up these two pages:
> http://www.hibernate.org/118.html#A8
> http://www.javalobby.org/java/forums/t43955.html
>
> but, I am not sure if it works as Teneo implements its own persistable
> elist....
>
> then Hibernate also has the lazy="extra" attribute on a list-mapping
> but this is not implemented yet with Teneo (there is a bugzilla for
> this but I did not have time yet).
>
> gr. Martin
>
> Anthony wrote:
>> Hi,
>>
>>
>>
>> Since it is no effect to setMaxResult for the query 'select parent
>> fetch join parent.children ...' , I wonder if there is one way to let
>> lazy collection only return certain numbers of itetm.
>>
>> I try to use parent.getChildren().iterator(),but once
>> iterator.hasNext
>> () or iterator.next() get called, all the item are loaded.
>>
>> Any workaround idea ?
>>
>> Thanks in advance!
>>
>> Anthony Lee
>
>
Re: [Teneo]lazy collection pagination [message #82726 is a reply to message #82725] Thu, 10 May 2007 10:05 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
It is trial and error, but what you can try is the following:
- cast the collection to PersistableDelegateList
- and then use the getDelegate method on this persistabledelegatelist to get to the underlying
hibernate persistentlist and pass this one to the create filter method.

if the getDelegate returns an elist then you need to track if it also has a delegate..., eventually
there should be an underlying hibernate list.

gr. Martin

Anthony wrote:
> Hi,
> Thank you for your tips.
>
> According to http://www.javalobby.org/java/forums/t43955.html,
> ============================================================ ==========
> 4 . At 12:46 PM on Aug 23, 2005, R.J. Lorimer wrote:
> Reply
> Re: Hibernate: Filter Collections
> Sandro,
>
> That's the beauty of filtered collections, when they are lazy, they don't
> generate 2 select statements.
>
> When you call owner.getPets() it simply gives you the
> 'PersistentCollection' from Hibernate, which doesn't actually invoke the
> SQL until you use it (say via owner.getPets().iterator().next()). Because
> of that, you can add a filter to it which is simply a way of adding
> additional criteria to the SQL that will be invoked to initialize the
> collection.
> ============================================================ ============
>
> I create a method just like this:
>
> public static List getPagingResult(Object collection, int beginIndex, int
> pageSize){
> final Query pagingFilter = sessionController.getSession().createFilter
> (collection,"");
> pagingFilter.setFirstResult(begin);
> pagingFilter.setMaxResult(pageSize);
> List pageContent = pagingFilter.list();
> }
>
> and then I try to use the lazy collection as the first parameter to call
> this method.
>
> But I got an exception :
>
> org.hibernater.QueryException:The collection was unreferenced
>
> In http://www.hibernate.org/117.html#A11, it says the reason is:
>
> Collection filters are for filtering persistent collections, not query
> results.
>
> But it is persistent collection.
>
> ?
>
> Anthony
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Martin Taal <mtaal@elver.org> wrote in
> news:f1uo0b$com$1@build.eclipse.org:
>
>> Hi,
>> A quick google search turned up these two pages:
>> http://www.hibernate.org/118.html#A8
>> http://www.javalobby.org/java/forums/t43955.html
>>
>> but, I am not sure if it works as Teneo implements its own persistable
>> elist....
>>
>> then Hibernate also has the lazy="extra" attribute on a list-mapping
>> but this is not implemented yet with Teneo (there is a bugzilla for
>> this but I did not have time yet).
>>
>> gr. Martin
>>
>> Anthony wrote:
>>> Hi,
>>>
>>>
>>>
>>> Since it is no effect to setMaxResult for the query 'select parent
>>> fetch join parent.children ...' , I wonder if there is one way to let
>>> lazy collection only return certain numbers of itetm.
>>>
>>> I try to use parent.getChildren().iterator(),but once
>>> iterator.hasNext
>>> () or iterator.next() get called, all the item are loaded.
>>>
>>> Any workaround idea ?
>>>
>>> Thanks in advance!
>>>
>>> Anthony Lee
>>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo]lazy collection pagination [message #82811 is a reply to message #82726] Thu, 10 May 2007 10:25 Go to previous message
Anthony Lee is currently offline Anthony LeeFriend
Messages: 114
Registered: July 2009
Senior Member
Martin Taal <mtaal@elver.org> wrote in
news:f1uqp6$k7c$1@build.eclipse.org:

> It is trial and error, but what you can try is the following:
> - cast the collection to PersistableDelegateList
> - and then use the getDelegate method on this persistabledelegatelist
> to get to the underlying hibernate persistentlist and pass this one to
> the create filter method.
>
> if the getDelegate returns an elist then you need to track if it also
> has a delegate..., eventually there should be an underlying hibernate
> list.
>
> gr. Martin
>
> Anthony wrote:
>> Hi,
>> Thank you for your tips.
>>
>> According to http://www.javalobby.org/java/forums/t43955.html,
>>
============================================================ ==========
>> 4 . At 12:46 PM on Aug 23, 2005, R.J. Lorimer wrote:
>> Reply
>> Re: Hibernate: Filter Collections
>> Sandro,
>>
>> That's the beauty of filtered collections, when they are lazy, they
>> don't generate 2 select statements.
>>
>> When you call owner.getPets() it simply gives you the
>> 'PersistentCollection' from Hibernate, which doesn't actually invoke
>> the SQL until you use it (say via owner.getPets().iterator().next()).
>> Because of that, you can add a filter to it which is simply a way of
>> adding additional criteria to the SQL that will be invoked to
>> initialize the collection.
>>
============================================================ ==========
>> ==
>>
>> I create a method just like this:
>>
>> public static List getPagingResult(Object collection, int beginIndex,
>> int pageSize){
>> final Query pagingFilter =
>> sessionController.getSession().createFilter (collection,"");
>> pagingFilter.setFirstResult(begin);
>> pagingFilter.setMaxResult(pageSize);
>> List pageContent = pagingFilter.list();
>> }
>>
>> and then I try to use the lazy collection as the first parameter to
>> call this method.
>>
>> But I got an exception :
>>
>> org.hibernater.QueryException:The collection was unreferenced
>>
>> In http://www.hibernate.org/117.html#A11, it says the reason is:
>>
>> Collection filters are for filtering persistent collections, not
>> query results.
>>
>> But it is persistent collection.
>>
>> ?
>>
>> Anthony
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Martin Taal <mtaal@elver.org> wrote in
>> news:f1uo0b$com$1@build.eclipse.org:
>>
>>> Hi,
>>> A quick google search turned up these two pages:
>>> http://www.hibernate.org/118.html#A8
>>> http://www.javalobby.org/java/forums/t43955.html
>>>
>>> but, I am not sure if it works as Teneo implements its own
>>> persistable elist....
>>>
>>> then Hibernate also has the lazy="extra" attribute on a list-mapping
>>> but this is not implemented yet with Teneo (there is a bugzilla for
>>> this but I did not have time yet).
>>>
>>> gr. Martin
>>>
>>> Anthony wrote:
>>>> Hi,
>>>>
>>>>
>>>>
>>>> Since it is no effect to setMaxResult for the query 'select parent
>>>> fetch join parent.children ...' , I wonder if there is one way to
>>>> let lazy collection only return certain numbers of itetm.
>>>>
>>>> I try to use parent.getChildren().iterator(),but once
>>>> iterator.hasNext
>>>> () or iterator.next() get called, all the item are loaded.
>>>>
>>>> Any workaround idea ?
>>>>
>>>> Thanks in advance!
>>>>
>>>> Anthony Lee
>>>
>>
>
>

Hi ,

Yes, it works!
Thanks a lot!

Anthony
Re: [Teneo]lazy collection pagination [message #606645 is a reply to message #82722] Thu, 10 May 2007 09:18 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi,
A quick google search turned up these two pages:
http://www.hibernate.org/118.html#A8
http://www.javalobby.org/java/forums/t43955.html

but, I am not sure if it works as Teneo implements its own persistable elist....

then Hibernate also has the lazy="extra" attribute on a list-mapping but this is not implemented yet
with Teneo (there is a bugzilla for this but I did not have time yet).

gr. Martin

Anthony wrote:
> Hi,
>
>
>
> Since it is no effect to setMaxResult for the query 'select parent fetch
> join parent.children ...' , I wonder if there is one way to let lazy
> collection only return certain numbers of itetm.
>
> I try to use parent.getChildren().iterator(),but once iterator.hasNext
> () or iterator.next() get called, all the item are loaded.
>
> Any workaround idea ?
>
> Thanks in advance!
>
> Anthony Lee


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo]lazy collection pagination [message #606647 is a reply to message #82723] Thu, 10 May 2007 09:58 Go to previous message
Anthony Lee is currently offline Anthony LeeFriend
Messages: 114
Registered: July 2009
Senior Member
Hi,
Thank you for your tips.

According to http://www.javalobby.org/java/forums/t43955.html,
============================================================ ==========
4 . At 12:46 PM on Aug 23, 2005, R.J. Lorimer wrote:
Reply
Re: Hibernate: Filter Collections
Sandro,

That's the beauty of filtered collections, when they are lazy, they don't
generate 2 select statements.

When you call owner.getPets() it simply gives you the
'PersistentCollection' from Hibernate, which doesn't actually invoke the
SQL until you use it (say via owner.getPets().iterator().next()). Because
of that, you can add a filter to it which is simply a way of adding
additional criteria to the SQL that will be invoked to initialize the
collection.
============================================================ ============

I create a method just like this:

public static List getPagingResult(Object collection, int beginIndex, int
pageSize){
final Query pagingFilter = sessionController.getSession().createFilter
(collection,"");
pagingFilter.setFirstResult(begin);
pagingFilter.setMaxResult(pageSize);
List pageContent = pagingFilter.list();
}

and then I try to use the lazy collection as the first parameter to call
this method.

But I got an exception :

org.hibernater.QueryException:The collection was unreferenced

In http://www.hibernate.org/117.html#A11, it says the reason is:

Collection filters are for filtering persistent collections, not query
results.

But it is persistent collection.

?

Anthony

















Martin Taal <mtaal@elver.org> wrote in
news:f1uo0b$com$1@build.eclipse.org:

> Hi,
> A quick google search turned up these two pages:
> http://www.hibernate.org/118.html#A8
> http://www.javalobby.org/java/forums/t43955.html
>
> but, I am not sure if it works as Teneo implements its own persistable
> elist....
>
> then Hibernate also has the lazy="extra" attribute on a list-mapping
> but this is not implemented yet with Teneo (there is a bugzilla for
> this but I did not have time yet).
>
> gr. Martin
>
> Anthony wrote:
>> Hi,
>>
>>
>>
>> Since it is no effect to setMaxResult for the query 'select parent
>> fetch join parent.children ...' , I wonder if there is one way to let
>> lazy collection only return certain numbers of itetm.
>>
>> I try to use parent.getChildren().iterator(),but once
>> iterator.hasNext
>> () or iterator.next() get called, all the item are loaded.
>>
>> Any workaround idea ?
>>
>> Thanks in advance!
>>
>> Anthony Lee
>
>
Re: [Teneo]lazy collection pagination [message #606648 is a reply to message #82725] Thu, 10 May 2007 10:05 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
It is trial and error, but what you can try is the following:
- cast the collection to PersistableDelegateList
- and then use the getDelegate method on this persistabledelegatelist to get to the underlying
hibernate persistentlist and pass this one to the create filter method.

if the getDelegate returns an elist then you need to track if it also has a delegate..., eventually
there should be an underlying hibernate list.

gr. Martin

Anthony wrote:
> Hi,
> Thank you for your tips.
>
> According to http://www.javalobby.org/java/forums/t43955.html,
> ============================================================ ==========
> 4 . At 12:46 PM on Aug 23, 2005, R.J. Lorimer wrote:
> Reply
> Re: Hibernate: Filter Collections
> Sandro,
>
> That's the beauty of filtered collections, when they are lazy, they don't
> generate 2 select statements.
>
> When you call owner.getPets() it simply gives you the
> 'PersistentCollection' from Hibernate, which doesn't actually invoke the
> SQL until you use it (say via owner.getPets().iterator().next()). Because
> of that, you can add a filter to it which is simply a way of adding
> additional criteria to the SQL that will be invoked to initialize the
> collection.
> ============================================================ ============
>
> I create a method just like this:
>
> public static List getPagingResult(Object collection, int beginIndex, int
> pageSize){
> final Query pagingFilter = sessionController.getSession().createFilter
> (collection,"");
> pagingFilter.setFirstResult(begin);
> pagingFilter.setMaxResult(pageSize);
> List pageContent = pagingFilter.list();
> }
>
> and then I try to use the lazy collection as the first parameter to call
> this method.
>
> But I got an exception :
>
> org.hibernater.QueryException:The collection was unreferenced
>
> In http://www.hibernate.org/117.html#A11, it says the reason is:
>
> Collection filters are for filtering persistent collections, not query
> results.
>
> But it is persistent collection.
>
> ?
>
> Anthony
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Martin Taal <mtaal@elver.org> wrote in
> news:f1uo0b$com$1@build.eclipse.org:
>
>> Hi,
>> A quick google search turned up these two pages:
>> http://www.hibernate.org/118.html#A8
>> http://www.javalobby.org/java/forums/t43955.html
>>
>> but, I am not sure if it works as Teneo implements its own persistable
>> elist....
>>
>> then Hibernate also has the lazy="extra" attribute on a list-mapping
>> but this is not implemented yet with Teneo (there is a bugzilla for
>> this but I did not have time yet).
>>
>> gr. Martin
>>
>> Anthony wrote:
>>> Hi,
>>>
>>>
>>>
>>> Since it is no effect to setMaxResult for the query 'select parent
>>> fetch join parent.children ...' , I wonder if there is one way to let
>>> lazy collection only return certain numbers of itetm.
>>>
>>> I try to use parent.getChildren().iterator(),but once
>>> iterator.hasNext
>>> () or iterator.next() get called, all the item are loaded.
>>>
>>> Any workaround idea ?
>>>
>>> Thanks in advance!
>>>
>>> Anthony Lee
>>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo]lazy collection pagination [message #606650 is a reply to message #82726] Thu, 10 May 2007 10:25 Go to previous message
Anthony Lee is currently offline Anthony LeeFriend
Messages: 114
Registered: July 2009
Senior Member
Martin Taal <mtaal@elver.org> wrote in
news:f1uqp6$k7c$1@build.eclipse.org:

> It is trial and error, but what you can try is the following:
> - cast the collection to PersistableDelegateList
> - and then use the getDelegate method on this persistabledelegatelist
> to get to the underlying hibernate persistentlist and pass this one to
> the create filter method.
>
> if the getDelegate returns an elist then you need to track if it also
> has a delegate..., eventually there should be an underlying hibernate
> list.
>
> gr. Martin
>
> Anthony wrote:
>> Hi,
>> Thank you for your tips.
>>
>> According to http://www.javalobby.org/java/forums/t43955.html,
>>
============================================================ ==========
>> 4 . At 12:46 PM on Aug 23, 2005, R.J. Lorimer wrote:
>> Reply
>> Re: Hibernate: Filter Collections
>> Sandro,
>>
>> That's the beauty of filtered collections, when they are lazy, they
>> don't generate 2 select statements.
>>
>> When you call owner.getPets() it simply gives you the
>> 'PersistentCollection' from Hibernate, which doesn't actually invoke
>> the SQL until you use it (say via owner.getPets().iterator().next()).
>> Because of that, you can add a filter to it which is simply a way of
>> adding additional criteria to the SQL that will be invoked to
>> initialize the collection.
>>
============================================================ ==========
>> ==
>>
>> I create a method just like this:
>>
>> public static List getPagingResult(Object collection, int beginIndex,
>> int pageSize){
>> final Query pagingFilter =
>> sessionController.getSession().createFilter (collection,"");
>> pagingFilter.setFirstResult(begin);
>> pagingFilter.setMaxResult(pageSize);
>> List pageContent = pagingFilter.list();
>> }
>>
>> and then I try to use the lazy collection as the first parameter to
>> call this method.
>>
>> But I got an exception :
>>
>> org.hibernater.QueryException:The collection was unreferenced
>>
>> In http://www.hibernate.org/117.html#A11, it says the reason is:
>>
>> Collection filters are for filtering persistent collections, not
>> query results.
>>
>> But it is persistent collection.
>>
>> ?
>>
>> Anthony
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Martin Taal <mtaal@elver.org> wrote in
>> news:f1uo0b$com$1@build.eclipse.org:
>>
>>> Hi,
>>> A quick google search turned up these two pages:
>>> http://www.hibernate.org/118.html#A8
>>> http://www.javalobby.org/java/forums/t43955.html
>>>
>>> but, I am not sure if it works as Teneo implements its own
>>> persistable elist....
>>>
>>> then Hibernate also has the lazy="extra" attribute on a list-mapping
>>> but this is not implemented yet with Teneo (there is a bugzilla for
>>> this but I did not have time yet).
>>>
>>> gr. Martin
>>>
>>> Anthony wrote:
>>>> Hi,
>>>>
>>>>
>>>>
>>>> Since it is no effect to setMaxResult for the query 'select parent
>>>> fetch join parent.children ...' , I wonder if there is one way to
>>>> let lazy collection only return certain numbers of itetm.
>>>>
>>>> I try to use parent.getChildren().iterator(),but once
>>>> iterator.hasNext
>>>> () or iterator.next() get called, all the item are loaded.
>>>>
>>>> Any workaround idea ?
>>>>
>>>> Thanks in advance!
>>>>
>>>> Anthony Lee
>>>
>>
>
>

Hi ,

Yes, it works!
Thanks a lot!

Anthony
Previous Topic:[Teneo] Problem using Proxy Annotation
Next Topic:[Teneo] Integrating Teneo-Struts-Tomcat
Goto Forum:
  


Current Time: Thu Apr 25 00:57:31 GMT 2024

Powered by FUDForum. Page generated in 0.03792 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top