// We don't have a reference to the selected Product.
// So first we have to lookup the object,
// we do this by a query by example (QBE):
// 1. build an example object with matching primary key values:
Product example = new Product();
example.setId(id);
// 2. build a QueryByIdentity from this sample instance:
Query query = new QueryByIdentity(example);
try
{
// start broker transaction
broker.beginTransaction();
// lookup the product specified by the QBE
Product toBeDeleted = (Product) broker.getObjectByQuery(query);
// now ask broker to delete the object
broker.delete(toBeDeleted);
// commit transaction
broker.commitTransaction();
}