Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

entity bean remove

 
Chetan Sahasrabudhe
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

Enitity bean calls remove(Object object) method on entity bean, then the bean is deleted.

What happens when two EJBObjects (EJBObject_1 and EJBObject_2) are representing a single row say
#10-Valentin Crettaz

Now EJBObject_1 gets a call to remove #10 and that too it is in transaction. What will be the containers approach.

1. Delete the row, remove EJBObject_1, return bean to pool, but then EJBObject_2 will be in a bad state, as the client might get exception on calling methods on EJBObject_2.

2. Do not delete the row, more of like do nothing, but then EJBObject_1 is in transaction and the operation is not happening as desired.

How to handle this situation in my client code ?
 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Enitity bean calls remove(Object object) method on entity bean, then the bean is deleted.


Normally, it is your client codes that invokes the remove(Object pk) method rather than another entity bean. Remember, an entity bean is a noun. It represents something rather than do something (verb - session beans). If you're thinking of the parent-child (CMR) kind of relationship, you'd be using cascade delete in the DD instead.

What happens when two EJBObjects (EJBObject_1 and EJBObject_2) are representing a single row say #10-Valentin Crettaz

Now EJBObject_1 gets a call to remove #10 and that too it is in transaction. What will be the containers approach.


When the client invokes a method from the component interface of a bean that had been removed, an exception will be thrown. Thats the way containers inform the client that the bean is no longer there.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic