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

Transaction across methods in Entity Beans?

 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the spec, I understand that in stateless/message-driven beans, the transaction starts/ends in the same method.In a stateful session bean the transaction may start in one method and end in another method.
What about entity beans? Can my transaction start and end in different methods?
 
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vish,
The very notion of a transaction doed not hold good for a Entity Bean bcoz the Entity Beans are suppose to represent domain objects or more precisely
rows in database tables. In a case if there is a requirement of domain biz logic wherein you need to start a transaction it should be BMP Entity Beans
and offcourse since the container maintains a pool of entity bean instances which implies that it can be assigned to any client or it can be swapped in its POOLED state which further implies it acts like stateless. So the transaction cant be forwaded to another method.It needs to end in a single method.
Rishi
SCJP,SCWCD,IBM OOAD
 
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Entity Beans must use Container Managed Transactions and there is no possibility of starting and ending in different methods
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys!....
I couldn't grasp this from the spec.
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,
While agreeing that transactions are not something an entity bean programmer has to worry about, I don't think I can agree that they don't exist.
Section 14.2.3 of the specification shows how passivation and activation of an entity bean occurs while in a transaction. So entity beans can be used within transactions, and do have state.
Which makes sense, otherwise we could not have the concept of rollback on an entity bean.
Sivasundaram is correct with his statement that entity beans must have container managed transactions (section 17.3.1). The second part of his statement I am not so sure about (because I am pedantic).
Since you cannot progamatically start a transaction from within an entity bean's method, logically you cannot end it in a different method. But since a transaction could be started from within a session bean or from the client itself, it is quite possible that two different methods of the entity bean could be called from within the same transaction.
Regards, Andrew
 
Sivasundaram Umapathy
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Andrew,may be i can convince you by referring the life cycle diagrams of entity,SLSB,SFSB.If you see in entity and SLSB,you can can find after the invocation of a method,the bean returns to the method-ready state where as it is different in the case of SFSB.
 
Andrew Monkhouse
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sivasundaram,
I am not sure if I have argued a different point to you. You are correct that a transaction cannot be started in one method of an entity bean and completed in another method.
My comment was tangental to that: two separate methods of an entity bean can be called from within a transaction started by some other bean.
Regards, Andrew
 
Then YOU must do the pig's work! Read this tiny ad. READ IT!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic