File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes refresh state problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "refresh state problem" Watch "refresh state problem" New topic
Author

refresh state problem

Carlos Conti
Ranch Hand

Joined: Apr 21, 2010
Posts: 107
Hi there,

I am runnign some maintainance tasks and need to update hierarchy relationships between my entities. The process is successful. However I have to restart the application contianer in order to update the contents in the application. Therefore I am having a refresh problem in my Persistence methods.

Let me post the main two methods I use.



May there be something I am missing in the reading method, to get the most fresh version of the instance?

Thanks for your help.

Carlos .
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 550
What JPA provider are you using?

How does your maintenance task modify the database, directly or through JPA?
It seems like you are using a shared cache (L2 cache).

You need to either,
- clear / invalidate the cache after running your
- refresh your objects
- disable the shared cache

JPA 2.0 provides cache configuration and API. If using JPA 1.0, you will need to use configuration specific to your JPA provider.

See,
http://en.wikibooks.org/wiki/Java_Persistence/Caching


TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
Carlos Conti
Ranch Hand

Joined: Apr 21, 2010
Posts: 107
Hi James, thanks for your answer.
Let me clarify one point which may have not been clear enough in my first post.
On one side I use EclipseLink1.1 (the contained application, with Tomcat 6.0). The maintenance application is a pure batch task which we let run from time to time to update some pieces of information. On this side I use aswell EclipseLink 1.1 but since running it in my machine in a local copy of the database, I use a different persistenceunit. But both share the same ORM Mapping file. The point is that if I perform a change via the maintenance task, when running the web application at the same time (locally of course), the changes are not noticeable until I restart the web application.

So I use two different persistent units to attack the same db, merely to distinguist the context (RESOURCE_LOCAL vs. JTA). In fact in the server the db runs in the same box as the web application, however I preferred to have things settled from the very beginning.

Many thanks for your post. I will have a close look to the link you provided.

Carlos.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: refresh state problem
 
Similar Threads
Can't update a many-to-many relatonship
Can anyone translate this ??
problem whit MQQueueManager
Error en WebSphere
problem with a select query. Help!