Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Synchronizing two hibernate sessions

 
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[code]
I have two applications , say App1 and App1Admin. Both runs on a the JBoss server as separate wars. Both of them use Spring with Hibernate.

The scenario is if App1Admin changes something, The App1 should reload that
changes immediately in the same hibernate session, it is already running in.

So, what are the possible options to achieve this ? This is what, I could come up with, Please add/clarify :-

1. Use secondary cache (I have not explored much on that, It would be great if you can suggest any good paper/tutorial, which achieves this using Spring on top of Hibernate )

2. Write MBeans in App1, so whenever App1Admin goes to change something, it also invokes the MBean exposed by App1, so now App1 is aware that something has been changed, so it should reload that in the session it is running already..(I have not explored the JMX with Spring, so will have to do that..if you can add some references, suggestions, that would be great..)

3. Similar to the second option. But this time, whenever App1Admin goes to perform the updates, there is some listener program between Hibernate and the Database (or say a Trigger), which calls the App1 to reload the things..
(Please add your ideas..and resources..)

[code]
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well secondary cache is probably the only solution for you, but it won't help detached objects getting updated, and you have to somehow make it so that the two apps can point to the exact same cache region. I am actually not sure if you can do that at all. Haven't really had to.

It is like if you have a legacy system that can also change the data underneath you. In this scenario there is no way to let the Hibernate application know that they underlying database has changed, in either first or second level cache. In this scenario you can always set a timeout for the data in the second level cache to refresh itself after the time has elapsed.

Mark
 
The moth suit and wings road is much more exciting than taxes. Or this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic