• Post Reply Bookmark Topic Watch Topic
  • New Topic

Transaction and cache update help  RSS feed

 
Dean Pullen
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • 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?
 
Rob Spoor
Sheriff
Posts: 21092
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to JDBC.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37249
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 37249
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 37249
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!