Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Inserts and Caching

> Does the @Cache NONE actually helps? I wasn't able to find out if the
object was cached.

No do not use NONE, to disable the shared cache use shared=false.  NONE
should generally only be used for simple objects without relationships.

> Ok, but then the transaction is committed and restarted. In case of a
> rollback I have "unstable" data since the part before the flush wasn't
> rolled back.

No flush() does not commit the transaction, only commit() commits the
transaction, flush() just writes the SQL to the database, rollback will
still rollback everything from the point of the begin().



ossaert wrote:
> 
> Thanks for the follow-up.
> 
> 
> James Sutherland wrote:
>> 
>> Are you concerned with caching across transaction or within the same
>> transaction?
>> 
> 
> It is the caching within the same transaction. Let's say in one
> transaction I have to persist 5000 objects which I do not need afterwards.
> They should not unnecessary remain in memory. When a couple of requests
> are running, then the memory is filled up pretty quickly.
> 
> Does the @Cache NONE actually helps? I wasn't able to find out if the
> object was cached.
> 
> 
> James Sutherland wrote:
>> 
>> Across transaction you can disable caching using the persistence.xml
>> property,
>> "eclipselink.cache.shared.default"="false".  Or you can set the size or
>> type of the cache to control how many objects are cached.
>> 
> 
> Thanks for the tip. 
> 
> 
> James Sutherland wrote:
>> 
>> For avoiding caching within a single transaction, the best way is to
>> flush() then clear() the EntityManager.  You could do this for each
>> object, or probably better for each batch of objects.
>> 
> 
> Ok, but then the transaction is committed and restarted. In case of a
> rollback I have "unstable" data since the part before the flush wasn't
> rolled back.
> 
> Thanks
> Jan
> 
> 


-----
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/Inserts-and-Caching-tp24109228p24167301.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top