You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Phillip Rhodes <rh...@yahoo.com> on 2002/03/09 04:48:15 UTC

create new object in db from existing object?

Using TDK 2.1 and I want to provide "copy" functionality.
For example, "copy order" will grab the order object from the database and 
create a new order object, and dependent order line items.

When I grab the order from the db, I setNew to true and save, but the ID of 
the object is not refreshed.
         int orderId = 1;
         Order entry = getOrder(orderId);
         entry.setModified(true);
         entry.setNew(true);
         entry.setOrderDescription("Copy of " + entry.getOrderDescription());
         Vector ois= entry.getOrderItems();
         entry.save();
         //question items...
         Iterator iterator = ois.iterator();
         while (iterator.hasNext()) {
             OrderItem oi = (OrderItem )iterator.next();
             oi.setOrderId(entry.getOrderId());
             oi.setModified(true);
             oi.setNew(true);
             oi.save();
         }
	System.out.println(order.getOrderId());
	
//displays orderid of first order.


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>