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.
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).]