Hi ,
I am using cayenne 2.
I want to update an employee object. This object is related to employee
table in the db.
I generated this data object(along with it's super class) and table query
using modeler.
I am able to write insert, delete and select methods for this object easily.
can you tell me whether the below is the correct way to update/modify the
object?
I thought that the object that is sent for updation / modification usually
exists with data context, as the object is to be retrieved from the
database. During this getting/selecting process using data context, it will
be registered with data context. So, i can use localobject without any
doubt. all the cayenne examples lack modification code.
Object dataObj =
this.getDataContext().localObject(employeeDOProto.getObjectId(),employeeDOProto);
EmployeeDO anEmployeeDO = null;
if(dataObj != null) {
anEmployeeDO = (EmployeeDO)dataObj;
anEmployeeDO.setPersistenceState(PersistenceState.MODIFIED);
}
this.commitChanges();
--Yours Sincerely, Devatha Sridhar
This archive was generated by hypermail 2.0.0 : Fri Jul 17 2009 - 15:38:11 EDT