• 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

why use ctx.getPrimaryKey() to remove entitybean

 
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Friends,
I was reading entity beans from ed roman, there it is mentioned that to find out which entity bean is to be removed(when ejbRemove() is invoked). we should take primary key from ctx.getPrimaryKey(). My problem is that each entity bean instance represents a single row in a table, so we can easily store primary key as an instance variable, and use that variable whenever required. why take trouble to call ctx.getPrimaryKey()?
plz clear my doubts
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's probably to be on the safe side, to ensure that the correct bean is removed. As bean instances are pooled by the container, it is possible that an instance variable representing the PK field might not get set correctly when the bean instance is bought into an active state with identity.
Anybody else have any thoughts about this?
Simon
reply
    Bookmark Topic Watch Topic
  • New Topic