-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Embedded EJB - OutOfMemory Exception
PostPosted: Wed Sep 27, 2006 1:40 pm 
Beginner
Beginner

Joined: Tue Sep 19, 2006 11:26 am
Posts: 33
Hi,

I have written an embedded EJB application which extracts data from a series of CSV files and writes them to a MySQL 4.0.27 database.

There is ~ 25000 records that need to be imported into the database (across a number of different CSV files). I want to write this data in a single transaction so that if there is any problems processing any of the files, I can just stop and none of the data be committed to the database.

The problem that I am having is effectively a memory leak. As I understand it wrapping the insertion of the data in a transaction like I am is causing the objects to be stored in first-level cache before being comitted to the database. Since I am processing a large number of files this is resulting in an Out of memory exception before I have processed all of the data - although I say large I don'e see this number of records as extraordinarily large, just large enough to cause me problems :). I have come across ways of configuring the second level cache some of which cache the data to disk. Is it possible to do something similar for first-level cache? The closest I have got is articles such as http://www.informit.com/articles/article.asp?p=353736&seqNum=5&rl=1 which says something along the lines of "Nobody ever configures first-level cache". Or maybe there is some other way round my problem.

Thanks.

Simon


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 1:56 pm 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
How about Session.flush + Session.clear.
Or using StatelessSession?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 2:22 pm 
Beginner
Beginner

Joined: Tue Sep 19, 2006 11:26 am
Posts: 33
I've tried using the Embedded EJB equivalent of Session.flush() and Session.clear() (EntityManager.flush() and EntityManager.clear()) but this didn't help either.

When you say:
Quote:
Or using StatelessSession

What do you mean exactly? All my dao's are stateless but I haven't specifically configured the session to be stateless - how would I do this and how would it help?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 2:29 pm 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
s1mm0t wrote:
What do you mean exactly?


If you are not bound to EM, Hibernate has a notion of StatelessSession (look it up in API) - which might help you.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 28, 2006 9:24 am 
Beginner
Beginner

Joined: Tue Sep 19, 2006 11:26 am
Posts: 33
Stateless sessions sounded promising - in fact they sounded exactly what I was looking for, but I haven't been able to find out how / if at all its possible to make use of them from embedded EJB 3.0.

I haven't been able to find any documentation and I've tried looking at the source code as well.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.