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

Entity beans CMP demarcation...

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

I found this in the EJB spec:


For CMP entity beans, only the Required, RequiresNew, or Mandatory transaction attributes should be used for the transactional methods defined in the bean's component and home interface.



I am not really sure why this is so, I mean what is wrong with using NotSupported, Supports or Never? If I have my own business methods in an entity bean that I don't want to be in a transaction how could I do this?

Granted, with an entity bean mapped to a persistent store, I would most likely need to execute inside a transaction, but what if I didn't?

Anyone who had any ideas about this please help!

Thanx.

James.
[ November 09, 2004: Message edited by: James Turner ]
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The reason you cannot use the other three transaction attributes viz., Supports, Not Supported and Never is because entity beans are always transactional i.e. they have a meaningful transaction context. The other three transaction attributes allow (or enforce) the entity bean's method to run under an unspecified transaction context.

The reason why entity beans are always transactional is because they model shared, persistent business data (and methods that act on the business data). Since they (as in-memory objects) represent persistent data, they need to synchronize themselves with a persistent data store through calls to ejbLoad() and ejbStore(). The use of the ejbLoad and ejbStore methods for caching an entity object�s state (which is what an entity bean does) in the instance works well only if the Container can use transaction boundaries to drive the ejbLoad and ejbStore
methods. When one of the three attributes specified above is assigned to a remote interface or a home business method, the corresponding
enterprise bean class method executes with an unspecified transaction context. This means that the Container does not have any well-defined transaction boundaries to drive the ejbLoad and ejbStore methods on the instance.

Therefore, the ejbLoad and ejbStore methods become unreliable under the above scenario. This would result in a condition where the entity bean's in-memory state does not match the persistent data state which is highly undesirable.

Hope this helps...
 
James Turner
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the response...

That helped a lot.

Regards,

James.
 
reply
    Bookmark Topic Watch Topic
  • New Topic