File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes EJB QL - Changes with data in Table NOT REFLECTED 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 "EJB QL - Changes with data in Table NOT REFLECTED" Watch "EJB QL - Changes with data in Table NOT REFLECTED" New topic
Author

EJB QL - Changes with data in Table NOT REFLECTED

Nitin Sinha
Greenhorn

Joined: May 08, 2008
Posts: 17
Here is my scenario -

I have an Entity Bean (MyTable) -





I Have a Session Bean (MySession) -





Now, I build Entity & Session Bean in a JAR file and call them in Client file below.

AND I Have a Client File (Client.java)







Now, my problem is that when i call this method getListValues() of Client.java, it returns the result of the query specified in Session Bean but when i go and edit the table in the backend - Commit the values in the backend itself and then call this method, it fetches old values.

How Can I call em.refresh() here? Where Do i need to call em.refresh()? In the client file or Session Bean. If in the client file then how will it recognize em (EntityManager) in Client file?

Do I also need to call em.flush along with refresh ?
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457


EntityManager.clear()

Clear the persistence context, causing all managed entities to become detached. Changes made to entities that have not been flushed to the database will not be persisted.


That's kind of heavy handed, so you likely want to pull the clear() call into its own method and only invoke it when necessary.


Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB QL - Changes with data in Table NOT REFLECTED
 
Similar Threads
Problem -EJB3+JPA+HIbernate
Problem with refresh() method of EntityManamger in JPA
Answers of Sun's Free Proficiency Assessment
org.hibernate.QueryException!
design decision: variation of session fassade