• Post Reply Bookmark Topic Watch Topic
  • New Topic

Retrieval After Updation - Must Use EJB Finder?

 
James Gordon
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In my session bean, I've a method which contains some code
to update a record (through EJB setter). Subsequently,
a DAO (JDBC) is used to retrieve that record. Below is to
illustrate:



What I notice is that the result from the DAO is without
the changes. Ok, maybe it's not committed yet, so I tried
providing dirty read hints in my SQL. It's no used either,
the DAO still see the old values.

However, if I would to use the home interface finder method to
retrieve instead of the DAO, I would be able to see the changes.

Can someone please enlighten me on why DAO+dirty read can't
see the changes but the result from EJB finder is with the changes?


Thanks in advance.

Regards.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35716
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James,
EJB caches updates until it is flushed so the changes aren't known to the database yet. You can force a flush in EJB 3.0. (I don't remember whether you can for EJB 2.X). You'd still need the dirty read, but at least it would be in the database.
 
James Gordon
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, that explain it.
Thanks Jeanne.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!