Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Transaction confusion

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

I hope my question makes sense .. . .

In the EJB HeadFirst on p509 they say for CMT: Compulsory for entity beans.

Now . . . I have been using entity beans (and session beans for that matter) without using a single <container-transaction > in the <assembly-descriptor> section in my DD(ejb.jar). Does the container automaticly use the 'Required' attribute for ALL the buisiness methods for a entity bean? (I am using JBoss btw).

As for the session beans , <transaction-type>Container/Bean</transaction-type> is always present in the <enterprise-beans> section , but what if nothing for that bean is spesified in <container-transaction > in the <assembly-descriptor> section - does the methods run in no transaction or is it also 'Required' for all by default ?

Regards

Christiaan
 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

but what if nothing for that bean is spesified in <container-transaction > in the <assembly-descriptor> section - does the methods run in no transaction or is it also 'Required' for all by default ?



That is solely upto the container implementation. The spec does not guarantee what the transaction will be if the attribute is not specified.
 
Christiaan Pansegrouw
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks , but what about the comment :

CMT is Compulsory for entity beans.

does this mean that you can ONLY use CMT for entity bean , or CMT should ALWAYS be used for entity beans - or is this also up to your ejb-container's mercy ?
 
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Entity Beans can Use only CMT. The treansaction attribute if not specified then it depends upon the container. Weblogic 8.1 uses Supports as default. Not sure about jboss.

cheers
 
Christiaan Pansegrouw
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you choose not to use transactions for entity beans - ie. it is not a must to use transactions.
 
sawan parihar
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a intresting question . The EJBLoad and EJBStore methods are called with the start of a new transaction and not with every method call . That means on the basis of the transaction the container decides when to load and store.

I am not very sure but for select and finder methods specifiying no transaction makes sense but for other things we definitely need transactions.
 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am not very sure but for select and finder methods specifiying no transaction makes sense


In a way it does make sens. Suppose we have CMR fields that are loaded. If we are not in a transaction, the data that is loaded can be "inconsistent" by the time we finish initializing an entity...

Miki
 
Hey cool! They got a blimp! But I have a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic