• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

How to update row in CMP

Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using a Entity Bean CMP (assocuated with one table) which is called by a session bean.
CMP Entity Bean remote Interface has the get/set methods for the data need to be updated in the table.
From the session bean, I get the Entity Bean Home by look up and calling the findByPrimaryKey(KeyObject) and it returns the Remote.
Now my requirement is to update a few fields in the row which I get by the findByPrimaryKey(keyObject). How should I update the row?

I know the create() will call ejbCreate() and insert into... SQL will be called. How does the container know that it has to call the update .... SQL for this row.
Posts: 3892
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd suggest you read the EJB Spec, or better yet, read any of the dozens of books on EJB's. They all cover this process in detail.
What happens is that when the transaction ends that the new data (set using setter methods in the Entity bean) is written to the database with an UPDATE statement.
As to how it knows -- the simplest approach (which every container supports) is to simply write back ALL of the data from all of the EJB's used in the transaction with UPDATE statements. Smarter approaches use "dirty" flags to decide if any of the data has been changed (thus reducing the number of UPDATE statements). Only some containers support dirty flags
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
[This message has been edited by Kyle Brown (edited January 01, 2002).]
WARNING! Do not activate jet boots indoors or you will see a tiny ad:
a bit of art, as a gift, that will fit in a stocking
    Bookmark Topic Watch Topic
  • New Topic