[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] pojo mapping
|
It can still happen as part of the same transaction if you use two
UnitOfWorks in the same transaction that are not synchronized to the
transaction (JTA).
You could also use a single UOW but leverage an about to insert event on
Menu.
public class AboutToInsertMenuEvent extends DescriptorEventAdapter {
/**
* Add to the row about to be inserted.
* Add a field qualified with its table name.
*/
public void aboutToInsert(DescriptorEvent event) {
Record row = event.getRecord();
Menu menu = (Menu) event.getObject();
// ensure that the id from the Item object is used in the row
row.set("menu.ID", menu.getOwner().getId());
}
}
Just as a note in JPA you could use the flush() call after persisting
the Item and before attaching the Menu, no separate UOWs and no events
required. The latest Dali (Eclipse JPA Perspective project) has a lot
of the same functionality as the Workbench.
--Gordon
WP Moore-Taylor wrote:
it is a requirement and they need to be part of the same transaction.
I will try to create it using SQL as a test.
thanks for your help.
paul
On 19/06/2009 15:20:14, Gordon Yorke (gordon.yorke@xxxxxxxxxx) wrote:
> is auto_increment a requirement for sequencing? If it is you will want
> to insert the Item then attach the Menu in a separate transaction (or
> depending on your environment just in a separate UOW). If auto
> increment is not a requirement then switch to a Sequence object (if
> available) or table based sequencing. Either of these two changes will
> allow the mappings I described to work for you in the way you are
> looking for.
> --Gordon
>
> WP Moore-Taylor wrote:
> > Gordon,
> >
> > We can add / remove from the objects just not