You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Miroslav Nachev <mi...@space-comm.com> on 2008/01/30 10:27:43 UTC
How to pre-persists and object in JDBCSequence.nextInternal() implementation
Hi,
I have custom JDBCSequence implementation where before to return the
generated Id I would like to persists one object which is required
(Foreign Key constrain) from the main object which will use the returned
Id from nextInternal() method.
How can I persists that object in the same transaction before the main
object to be persisted?
Regards,
Miro.
Re: How to pre-persists and object in JDBCSequence.nextInternal() implementation
Posted by Patrick Linskey <pl...@gmail.com>.
If you tell OpenJPA that a foreign key relationship exists between the
instances, then OpenJPA should automatically flush them in the
appropriate order.
If the one instance needs to be flushed even before IDs are assigned
to the second, you'll probably have to call em.flush() after calling
persist() on the first instance.
-Patrick
On Jan 30, 2008 11:40 AM, Miroslav Nachev <mi...@space-comm.com> wrote:
> I do that using native JDBC/SQL statement instead to use JPA techniques. Is
> that correct?
>
>
> Miro.
>
>
> On 1/30/08, Miroslav Nachev <mi...@space-comm.com> wrote:
> >
> > Hi,
> >
> > I have custom JDBCSequence implementation where before to return the
> > generated Id I would like to persists one object which is required
> > (Foreign Key constrain) from the main object which will use the returned
> > Id from nextInternal() method.
> >
> > How can I persists that object in the same transaction before the main
> > object to be persisted?
> >
> >
> > Regards,
> > Miro.
> >
>
--
Patrick Linskey
202 669 5907
Re: How to pre-persists and object in JDBCSequence.nextInternal() implementation
Posted by Miroslav Nachev <mi...@space-comm.com>.
I do that using native JDBC/SQL statement instead to use JPA techniques. Is
that correct?
Miro.
On 1/30/08, Miroslav Nachev <mi...@space-comm.com> wrote:
>
> Hi,
>
> I have custom JDBCSequence implementation where before to return the
> generated Id I would like to persists one object which is required
> (Foreign Key constrain) from the main object which will use the returned
> Id from nextInternal() method.
>
> How can I persists that object in the same transaction before the main
> object to be persisted?
>
>
> Regards,
> Miro.
>