• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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.
 
author
Posts: 3892
5
  • 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
------------------
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).]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic