OK, enough with the philosophical murmerings, the real issue:
Database programming from the good ol' days:
1. Find record in table Keys where keyname = "userid"
2. Lock record (Read/Write lock)
3. Read keyvalue from locked record
4. Increment keyvalue with 1
5. Write keyvalue to locked record
6. Unlock record
7. ... you now have a new, unique userid ...
The million dollar question: how do you achieve the same with Enterprise JAVA (entity beans)? After reading two books about it ("Mastering EJB II" and "Professional JAVA Server progamming"), reading every possible article on the web about EJB, I still haven't found the answer! I can't think of many database projects that wouldn't require the above functionallity, so I'm left to wonder why nobody has the answer...
-
Transactions: Aaarrghhh! (Part 2) (5 messages)
- Posted by: Koen Rousseau
- Posted on: August 27 2002 10:13 EDT
Threaded Messages (5)
- Transactions: Aaarrghhh! (Part 2) by Koen Rousseau on August 27 2002 11:07 EDT
- Transactions: Aaarrghhh! (Part 2) by William Kemp on August 27 2002 11:46 EDT
- Transactions: Aaarrghhh! (Part 2) by Dave Wolf on August 27 2002 16:17 EDT
-
Transactions: Aaarrghhh! (Part 2) by Dave Wolf on August 27 2002 09:01 EDT
- Transactions: Aaarrghhh! (Part 2) by Owen Fellows on August 29 2002 06:39 EDT
-
Transactions: Aaarrghhh! (Part 2) by Dave Wolf on August 27 2002 09:01 EDT
- Transactions: Aaarrghhh! (Part 2) by Dave Wolf on August 27 2002 16:17 EDT
-
Transactions: Aaarrghhh! (Part 2)[ Go to top ]
- Posted by: Koen Rousseau
- Posted on: August 27 2002 11:07 EDT
- in response to Koen Rousseau
From one of Sun's FAQ's:
"If a container uses only one bean instance per primary key, the container will synchronize access to the bean and therefore transaction isolation is unnecessary. Containers that use multiple instances per primary key depend on the underlying database for isolation."
So how do you know if your container uses one or multiple instances per primary key (whatever that means)? Does JBoss use 1 or more? How about Jonas? -
Transactions: Aaarrghhh! (Part 2)[ Go to top ]
- Posted by: William Kemp
- Posted on: August 27 2002 11:46 EDT
- in response to Koen Rousseau
You set it for WebLogic CMP in the weblogic-ejb-jar.xml file using the <transaction-isolation> element, oddly enough. The database must support the isolation level you set in the deployment descriptor before the ejb container can successfully set it. But, assuming the db does support the isolation level you are interested in, you can set it at the method level for each method in the bean.
I can't comment on the implementations of other vendors/products.
Bill -
Transactions: Aaarrghhh! (Part 2)[ Go to top ]
- Posted by: Dave Wolf
- Posted on: August 27 2002 16:17 EDT
- in response to William Kemp
Keon,
There have been a ton of posts on this subject in the Patterns section. Surf around there a bit and explore.
But basically you can do exactly what you describe in your case using a SessionBean or an EntityBean. What specifically was your problem with implementing that? (outside of the fact that it isnt very scalable. In that same thread I posted some slightly modified versions of that approach that avoid the table lock contention issues).
Dave Wolf
The Scupper Group
dave at scuppergroup dot com
-
Transactions: Aaarrghhh! (Part 2)[ Go to top ]
- Posted by: Dave Wolf
- Posted on: August 27 2002 21:01 EDT
- in response to Dave Wolf
Yowzers that came off sounding arrogant. I didn't mean it to be :)
Dave Wolf
The Scupper Group
dave at scuppergroup dot com
-
Transactions: Aaarrghhh! (Part 2)[ Go to top ]
- Posted by: Owen Fellows
- Posted on: August 29 2002 06:39 EDT
- in response to Dave Wolf
Hi,
There is a session bean and entity bean from opensymphony in there oscore package that will create a primary key for each EJB. You simple give it the class name of your bean and it creates and entry in table that is implemented by their session/entity beans.
Works well and as the key is a row in the database represented by an entity bean the EJB container should handle the concurrent updates.
Owen Fellows