Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • 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: 22579
122
Eclipse IDE Spring VI Editor 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: 40912
840
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: 40912
840
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: 40912
840
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic