• 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 bean remove

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I think he's gonna try to grab my monkey. Do we have a monkey outfit for this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic