You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by is_maximum <mn...@gmail.com> on 2008/12/21 14:16:20 UTC

need advice

Hi

we have a DAO class includes save() update() delete() etc. each business
methods in our stateless classes may have a number of CRUD operations and
all occur through that DAO class. 

Currently we don't use flush() method for each save() or update() so at the
end of the transaction (business method) everything will be flushed
automatically. 

but in some business methods because of their logic we have to put a
for-loop to process maybe more than 500 records. in this case, each loop may
contains a number of CRUD operations. In my opinion, we need to flush every
for example 200 operations have been applied. how to manage this? do you
have any idea? is this opinion correct?

I appreciate if you share your expriences on this with me.


-- 
View this message in context: http://n2.nabble.com/need-advice-tp1686591p1686591.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: need advice

Posted by is_maximum <mn...@gmail.com>.
Thanks Ognjen,

thanks for testing it. but unfortunately I had another problem. that is, our
DAO classes are stateless so I can't say for example after every 100
persistence call the flush(). I have to manage this from outside but
outside, once you invoked the persiste() method within DAO class the next
time you can't call flush() method because stateless session bean is
invalidated. 

the only workaround I found was to use UserTransaction and commit every say,
100 records




Ognjen Blagojevic-3 wrote:
> 
> Never thought about that, but sounded interesting enough for me to test.
> 
> I tried to persist 10000 instances of small entity beans in a loop, in 
> JVM with as little as 2MB of heap (-Xms2m -Xmx2m). Without flush(), it 
> run out of heap space at around ~2500. instance. Flushing it at every 
> 1000 instances, run the whole thing without a problem.
> 
> It seems that without flush() OpenJPA will store all the queued queries 
> on the heap (as expected). Regular flush() will free space on heap and 
> reduce the need for garbage collection.
> 
> So, my opinion would be to go for it.
> 
> -Ognjen
> 
> is_maximum wrote:
>> Hi
>> 
>> we have a DAO class includes save() update() delete() etc. each business
>> methods in our stateless classes may have a number of CRUD operations and
>> all occur through that DAO class. 
>> 
>> Currently we don't use flush() method for each save() or update() so at
>> the
>> end of the transaction (business method) everything will be flushed
>> automatically. 
>> 
>> but in some business methods because of their logic we have to put a
>> for-loop to process maybe more than 500 records. in this case, each loop
>> may
>> contains a number of CRUD operations. In my opinion, we need to flush
>> every
>> for example 200 operations have been applied. how to manage this? do you
>> have any idea? is this opinion correct?
>> 
>> I appreciate if you share your expriences on this with me.
>> 
>> 
> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/need-advice-tp1686591p2204108.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: need advice

Posted by Ognjen Blagojevic <og...@etf.bg.ac.rs>.
Never thought about that, but sounded interesting enough for me to test.

I tried to persist 10000 instances of small entity beans in a loop, in 
JVM with as little as 2MB of heap (-Xms2m -Xmx2m). Without flush(), it 
run out of heap space at around ~2500. instance. Flushing it at every 
1000 instances, run the whole thing without a problem.

It seems that without flush() OpenJPA will store all the queued queries 
on the heap (as expected). Regular flush() will free space on heap and 
reduce the need for garbage collection.

So, my opinion would be to go for it.

-Ognjen

is_maximum wrote:
> Hi
> 
> we have a DAO class includes save() update() delete() etc. each business
> methods in our stateless classes may have a number of CRUD operations and
> all occur through that DAO class. 
> 
> Currently we don't use flush() method for each save() or update() so at the
> end of the transaction (business method) everything will be flushed
> automatically. 
> 
> but in some business methods because of their logic we have to put a
> for-loop to process maybe more than 500 records. in this case, each loop may
> contains a number of CRUD operations. In my opinion, we need to flush every
> for example 200 operations have been applied. how to manage this? do you
> have any idea? is this opinion correct?
> 
> I appreciate if you share your expriences on this with me.
> 
>