Re: update / modify data object

From: Aristedes Maniatis (ar..aniatis.org)
Date: Fri Jul 17 2009 - 21:07:39 EDT

  • Next message: sridhar devatha: "Re: update / modify data object"

    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



    This archive was generated by hypermail 2.0.0 : Fri Jul 17 2009 - 21:08:21 EDT