Christopher Delahunt <christopher.delahunt_at_oracle.com> wrote:
> You haven't set the full pk for the LineItem. In
> RequestBean.addLineItem(), you have:
>
> LineItem lineItem = new LineItem(order, quantity,
> part.getVendorPart());
>
> Which: public LineItem(Order order, int quantity, VendorPart
> vendorPart) { this.order = order; this.orderId = order.getOrderId();
> this.quantity = quantity; this.vendorPart = vendorPart; }
>
> But you have a composite PK of orderId and itemId. So the second
> time you try to call this method with the same Order object, you get
> a second LineItem with the same pk (orderId=x, itemId=null) as the
> first LineItem - a detached entity.
Thanks. That was it. I added a getNextId method to Order, and call it
from LineItem's constructor. The example works now.
-ian
--
Ian Evans
ian dot evans at sun dot com
Java Enterprise Edition technical documentation