• 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
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Entity beans CMP demarcation...

 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Thank you for the response...

That helped a lot.

Regards,

James.
 
There's a city wid manhunt for this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic