permaculture playing cards
The moose likes EJB and other Java EE Technologies and the fly likes How to close a CMP Entity Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How to close a CMP Entity Bean" Watch "How to close a CMP Entity Bean" New topic

How to close a CMP Entity Bean

Alex Ioannou

Joined: Nov 14, 2001
Posts: 25
Hi there
I have a for loop going through an ArrayList of Maps. In each iteration all the data in the map is converted into a new EJB using a custom create method.
The problem is that the java/ejb container/whatever can't keep up and the database connections just mushroom until exceptions are thrown. How do a manually close the bean to free up the resources?
Is the fact that the arraylist might contain over 8,000 maps an issue?
And don't say a word about BMP as this is out of the question!!
At present I have (in shorthand)
Ajith Kallambella

Joined: Mar 17, 2000
Posts: 5782
There is nothing you can do to "release" a bean. Bean instances are managed by the container and it uses its own set of proprietary algorithms to determine when and which beans should be evicted from memory.
Coming back to your design, if you are inserting 8000 records in a single transaction perhaps you should try to hit the database directly. Entity beans are quite expensive and more so in situations like this one. Have you considered batch inserts using plain old JDBC?

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
I agree. Here's the link:
subject: How to close a CMP Entity Bean
jQuery in Action, 3rd edition