[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] The ScrollableCursor's issues

The objects will no longer be held by the UnitOfWork/EntityManager, but will
still be in the cache.  Depending on what caching you are using, they will
eventually garbage collect (weak references).  SoftWeak is the default cache
type, which will hold 100 objects using soft reference and the rest using
weak references, weak will garbage collect in the next gc, and soft will
garbage collect when memory is low.  You can change your cache type to weak
to allow better garbage collection.  You could potentially also set
dontMaintainCache() on the query to avoid the cache entirely.

If you set read-only on the query, you don't need to execute it with the
Session, using the EntityManager is fine.



dmitryerkin wrote:
> 
> Hi, James Sutherland!
> Thanks a lot for your help.
> 
> One your tip helped me but another did not help.
> I found settings for the transaction service and changed the value of
> timeout. It works.
> But a memory for the previous block is not released after the next block
> is getted although I changed my code:
> 
> 	ReadAllQuery queryByTime = new ReadAllQuery(OebsView.class, where);
> 	queryByTime.useScrollableCursor();
> 	queryByTime.setIsReadOnly(true);
> 	
> 	ut.setTransactionTimeout(60*60*24);
> 	ut.begin();
> 		
> 	jpaEM = org.eclipse.persistence.jpa.JpaHelper.getEntityManager(em);
> 	uow = jpaEM.getActiveSession().getActiveUnitOfWork();
> 	if(uow == null){
>  		System.out.println("uow is null");    		
>     		uow = jpaEM.getActiveSession().acquireUnitOfWork();
> 	}		
> 	cursorByTimeAndOrganizationId = (ScrollableCursor)
> uow.getParent().executeQuery(queryByTime);
> 
> 
> I could not try the third way which You advised because I could not find
> the class where the clear() method is declared.
> 
> 
> Regards,
> Dmitry
> 
> 
> 
> James Sutherland wrote:
>> 
>> You are executing the query in the UnitOfWork so all of the returned
>> objects will be managed (and not allowed to garbage collect).  If you
>> execute it in the Session (uow.getParent()), then the objects will not be
>> managed and free to gc, (but must be used as read-only).  You could also
>> call clear() in between each page, or set the query to be read-only
>> (setIsReadOnly(true) same as exec in session).
>> 
>> The rollback seems like it is cause because you have a transaction
>> timeout set somewhere in WAS or your DB.  You will need to find and
>> increase this timeout.
>> 
>> You could also potentially use JPA firstResult/maxResult to page the
>> results.
>> 
> 
> 


-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/The-ScrollableCursor%27s-issues-tp19392081p19511906.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.