cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aristedes Maniatis <...@maniatis.org>
Subject Re: update / modify data object
Date Sat, 18 Jul 2009 01:07:39 GMT
On 18/07/09 5:37 AM, sridhar devatha wrote:
> 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();
>

It isn't clear what you are trying to do with the code above. What is 
employeeDOProto? Why are you moving it to another context and then 
assigning it to a different variable?

Ari Maniatis

Mime
View raw message