Re: update / modify data object

From: sridhar devatha (devatha.sridha..mail.com)
Date: Fri Jul 17 2009 - 23:39:50 EDT

  • Next message: Aristedes Maniatis: "Re: update / modify data object"

    Hi Ari Maniatis
    Thank you for the reply. sorry. ignore the line of code for local object.
    Assume employeeDBProto is the object to be saved. It has the modified data.
    Do I need to write the entire update query to update and populate the data
    from the proto object into the query using expressions and velocity.

    On Sat, Jul 18, 2009 at 6:37 AM, Aristedes Maniatis <ar..aniatis.org>wrote:

    > 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
    >

    -- 
    

    Yours Sincerely, Devatha Sridhar



    This archive was generated by hypermail 2.0.0 : Fri Jul 17 2009 - 23:40:25 EDT