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

 
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 ?
 
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.
 
I've read about this kind of thing at the checkout counter. That's where I met this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic