EntityManager persist and/or clear?

2 messages Options
Embed this post
Permalink
Азамат Ш. Калимуллин

EntityManager persist and/or clear?

Reply Threaded More More options
Print post
Permalink

Hi.
I'm creating EntityManager instance and keep it open through whole application
cycle.
After doing em.persist() and objects still in session. Next em.persist()
produces sqls for current persist + sqls for previous persists.
After doing em.clear() problem resolved, but all object left with detached
state and has not session cache.
I think that em.clear() isn't be directly called from user code and should be
another way. So, help, please, with ideology.


signature.asc (204 bytes) Download Attachment
crispyoz

RE: EntityManager persist and/or clear?

Reply Threaded More More options
Print post
Permalink
I haven't had time to dig in this too deeply, but my experience with the
cache has been a little problematic. I have some integration events that
load data from XLS or CSV file and unless I programmatically call commit and
clear every 50 or so records (about 200 bytes per record) I end up with OOM
issues with a heap size o 1024mb and a single em instance. I would have
thought that OpenJPA would have managed this better.

Chris

OpenJPA 1.2.1

-----Original Message-----
From: Азамат Ш. Калимуллин [mailto:[hidden email]]
Sent: Wednesday, 21 October 2009 6:44 PM
To: [hidden email]
Subject: EntityManager persist and/or clear?


Hi.
I'm creating EntityManager instance and keep it open through whole
application cycle.
After doing em.persist() and objects still in session. Next em.persist()
produces sqls for current persist + sqls for previous persists.
After doing em.clear() problem resolved, but all object left with detached
state and has not session cache.
I think that em.clear() isn't be directly called from user code and should
be another way. So, help, please, with ideology.