• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Transaction and cache update help

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all.

I can't quite get my head around what can happen with data during (and after) a transaction.
Any advice (or reading material), as always, would be appreciated.

[Using JBoss 4.2.3 with EJB3/Hibernate JPA].

If during a transaction, we refresh a cache of data from the DB which we've added a value to during the transaction (thus it's not actually persisted yet, but 'available' within the transaction) but this data is also refreshed in another concurrent thread, what is the final outcome of the cache data?

Is it
a) the transaction's update and subsequent refresh from the DB, ignoring the other thread's update
b) the other thread's update, removing the transaction's changes
c) due to the 'isolation' in ACID, the data that's 'touched' within the cache class cannot be edited until the transaction is complete (the other thread is locked until the transaction is copleted)
d) something else


I'm hoping, and believe from the EJB spec, that it's c) but I just want a little clarification.



Many thanks...

Btw is this more suited to a different forum, say the EJB one?
 
Sheriff
Posts: 22796
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to JDBC.
 
author & internet detective
Posts: 41967
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dean,
Are you asking about the database cache or the Java cache? If the former, it is c. It the later, the update to Java values will not rollback.
 
Dean Pullen
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm pretty sure this is more relevent to EJB3 than JDBC...

It's a Java object containing other Java objects, detached from the database. Thus it's a 'Java cache', whatever you mean by that?
 
Jeanne Boyarsky
author & internet detective
Posts: 41967
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dean Pullen wrote:I'm pretty sure this is more relevent to EJB3 than JDBC...


Me too. I didn't want to move it until I was sure what you were asking. Moving to EJB forum.
 
Jeanne Boyarsky
author & internet detective
Posts: 41967
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dean Pullen wrote:It's a Java object containing other Java objects, detached from the database. Thus it's a 'Java cache', whatever you mean by that?


Yes. Which means that it is not ACID. The database itself is independent. Whatever gets stored in Java stays there even if the database transaction rolls back. If you wanted to rollback the cache, you'd have to store it in a temporary area and then transfer to the cache on database commit.
 
Morning came much too soon and it brought along a friend named Margarita Hangover, and a tiny ad.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic