• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Entity bean passivation by container

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friends,

i've a doubt regarding entity bean passivation.

According to EJB Spec 2.0 , the
container can passivate the entity bean in middle of transaction.
The following is paragraph from ejb spec.

"The container can choose to passivate an entity bean instance within a
transaction. To passivate an instance, the container first invokes the
ejbStore method to allow the instance to synchronize the database state
with the instance's state, and then the container invokes the ejbPassivate
method to return the instance to the pooled state."

So if container passivate the bean in middle of transaction then it would
invoke the ejbStore method and would update the database. So we are
updating the database with-out knowing the transaction result ( commit or
rollback ) In case of rollback, it would put the database in inconsistent
state.

Could any one please explain it ?
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sabari,

The point is the following:

(1) Storing something in the database means:

UPDATE data_info SET TITLE='Volcanos' WHERE ID = 100005; (=ejbStore)

(2) finishing a transaction means:

COMMIT

After (1) is running nobody else can see a change on the database until (2) runs (depending on your isolation level). The container may passivate your bean between (1) and (2).


Hope this helps

Severin
 
Sabari Unniramath
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanx for ur response.

what i get from ur reply is this..
once the container acquires the lock for a particular row in the database for a transaction, the lock will be released only after the transaction completes, no matter whatever happens with passivation..am i right ???
 
Severin Stoeckli
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, that's correct. Notice that "passivation" in Entity Beans is not the same as passivation in Stateful Session Beans. For Entity Beans it's only a "change of their role", not a "swap out to disk", although their state may be written to the disk too in ejbStore().

Severin
 
reply
    Bookmark Topic Watch Topic
  • New Topic