cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sridhar devatha <devatha.srid...@gmail.com>
Subject update / modify data object
Date Fri, 17 Jul 2009 19:37:36 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message