have it partially working now.

Regards

Ross Rotherham
----- Original Message ----- 
From: <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>
Sent: Wednesday, September 03, 2003 1:03 PM
Subject: newbie Q: Update creates new object


Have a problem with updates.

the record that I want to update is altered and then stored in the cache
with a new id but the changes are not written to the DB.  The original
record is no longer displayed.

When I try to view the altered record with the new id it doesn't exist.

Any help for where to look greatly appreciated  (the insert works fine)

//update code

        DynaValidatorForm _form = (DynaValidatorForm) form; // is in struts

        PersistenceBroker broker = null;
        broker = PersistenceBrokerFactory.defaultPersistenceBroker();
        // build object with matching id to retrive toBeEdited from DB
        SeminarVO search_vo = new SeminarVO();
        search_vo.setId(Long.valueOf(request.getParameter("id")));

        Query query = new QueryByCriteria(search_vo);
        broker.beginTransaction();

        //get toBeEdited
        SeminarVO vo = (SeminarVO) broker.getObjectByQuery(query);
        System.out.println("\n\nid = " + vo.getId());

        //populate toBeEdited
        populateVO(_form, vo);
        System.out.println("\n\n\n after populate id = " + vo.getId());

        broker.store(vo);
        broker.commitTransaction();

//

    public class SeminarVO  extends BaseVO{
    private Long id;
    private Date startDate;
    private Date endDate;
    private Integer stateId;
    private String location;
    private String city;
    // methods and other fields ommitted

// repository_user.xml

<class-descriptor class="com.bowtech.ojb.domainmodel.om.SeminarVO"
table="SEMINARS">

<field-descriptor name="id" column="id" jdbc-type="BIGINT" primarykey="true"
autoincrement="true"/>

<field-descriptor name="startDate" column="startDate" jdbc-type="DATE"/>

<field-descriptor name="endDate" column="endDate" jdbc-type="DATE"/>

<field-descriptor name="stateId" column="stateId" jdbc-type="INTEGER"/>

<field-descriptor name="location" column="location" jdbc-type="VARCHAR"/>

<field-descriptor name="address1" column="address1" jdbc-type="VARCHAR"/>

<field-descriptor name="address2" column="address2" jdbc-type="VARCHAR"/>

<field-descriptor name="city" column="city" jdbc-type="VARCHAR"/>

//other fields ommitted



Regards

Ross Rotherham



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to