Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [eclipselink-users] EclipseLink JpaEntityManager with JBoss Seam

Mathias,

Within the JpaEntityManager we actually use a subclass of the base UnitOfWorkImpl to address the ongoing transactional nature of the EntityManager. This RepeatableWriteUnitOfWork is held within the JpaEntityManager and upon each commit it implicitly continues in another transaction. Since you are automatically in another logical transaction after commit it is not possible to return the state of the previous transaction as we will be tracking a new change-set for future changes.

The JavaDocs on the UnitOfWork are accurate for the usage of our classic API where the base UnitOfWorkImpl is complete after a successful commit call and thus can maintain its state for the previous transaction as it is effectively closed.

We can obviously improve the comments on these to make this clear or at a minimum identify the concrete UnitOfWork implementations and have them document and differences.

The short story though for JpaEntityManager usage and access top the final change-set for a transaction is that the event mechanism is what you need to use.

Doug


-----Original Message-----
From: Mathias Walter [mailto:mathias.walter@xxxxxxx]
Sent: Monday, July 14, 2008 8:46 AM
To: EclipseLink User Discussions
Subject: RE: [eclipselink-users] EclipseLink JpaEntityManager with JBoss
Seam


Hi,

> After the commit of a transaction the JpaEntityManager has 
> its transaction context (UnitOfWork) reset so that developers 
> can continue working with the EntityManager. If you look at 

But than the documentation would be incorrect.

--
Regards,
Mathias

> using a SessionEventListener you can get a callback during 
> the UnitOfWork commit cycle to access the change-set.
> 
> Doug
> 
> -----Original Message-----
> From: Mathias Walter [mailto:mathias.walter@xxxxxxx]
> Sent: Monday, July 14, 2008 6:16 AM
> To: EclipseLink User Discussions
> Subject: RE: [eclipselink-users] EclipseLink JpaEntityManager 
> with JBoss
> Seam
> 
> 
> > Ah, I was thinking getCurrentChanges...
> 
> So you don't know why it is null?
> 
> > 
> > ./tch
> > 
> > 
> > On Mon, Jul 14, 2008 at 1:57 AM, Mathias Walter 
> > <mathias.walter@xxxxxxx> wrote:
> > > Hi,
> > >
> > >> If you just committed wouldn't it make sense for the 
> > change set to be
> > >> empty/null?
> > >
> > > according to the doc of UnitOfWork:
> > >
> > > public UnitOfWorkChangeSet getCurrentChanges()
> > > ADVANCED: This method Will Calculate the chages for the 
> > UnitOfWork. Without
> > > assigning sequence numbers
> > > This is a Computationaly intensive operation and should be 
> > avoided unless
> > > necessary. A valid changeSet, with sequencenumbers can be 
> > collected from the
> > > UnitOfWork After the commit is complete by calling
> > > unitOfWork.getUnitOfWorkChangeSet()
> > >
> > > AND
> > >
> > > public UnitOfWorkChangeSet getUnitOfWorkChangeSet()
> > > ADVANCED: Returns the currentChangeSet from the UnitOfWork. 
> > This is only
> > > valid after the UnitOfWOrk has commited successfully.
> > >
> > > I do not use UnitOfWork explicit. I do tx = em.getTransaction(),
> > > em.merge(entity) and then tx.commit(). em.getUnitOfWork() 
> > returns the
> > > UnitOfWork in this way also. But why is the 
> > UnitOfWorkChangeSet null?
> > >
> > > In the log I can see that only the changed fields of the 
> > entity are included
> > > in the update SQL statement. So the changeset is calculated.
> > >
> > > How to access it?
> > >
> > > --
> > > Regards,
> > > Mathias
> > >
> > >>
> > >> ./tch
> > >>
> > >>
> > >> On Sun, Jul 13, 2008 at 3:45 PM, Mathias Walter
> > >> <mathias.walter@xxxxxxx> wrote:
> > >> > Hi,
> > >> >
> > >> > I can call entityManager.getDelegate() which returns the 
> > EclipseLink
> > >> > JpaEntityManager. Unfortunatelly,
> > >> getUnitOfWork().getUnitOfWorkChangeSet()
> > >> > returns null after commit.
> > >> >
> > >> > How can I get the UnitOfWorkChangeSet? Do I have to enable
> > >> something else?
> > >> >
> > >> > --
> > >> > Regards,
> > >> > Mathias
> > >> >
> > >> >> -----Original Message-----
> > >> >> From: eclipselink-users-bounces@xxxxxxxxxxx
> > >> >> [mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of
> > >> >> Mathias Walter
> > >> >> Sent: Sunday, July 13, 2008 10:03 AM
> > >> >> To: 'EclipseLink User Discussions'
> > >> >> Subject: [eclipselink-users] EclipseLink JpaEntityManager
> > >> >> with JBoss Seam
> > >> >>
> > >> >>
> > >> >> Hi,
> > >> >>
> > >> >> I'm using JBoss Seam and EclipseLink together. Now I want to
> > >> >> access the
> > >> >> ObjectChangeSets.
> > >> >> But they are only accessable via the
> > >> >> org.eclipse.persistence.jpa.JpaEntityManager and not via
> > >> >> javax.persistence.EntityManager or via the Seam injected
> > >> >> org.jboss.seam.persistence.EntityManagerProxy.
> > >> >>
> > >> >> Does anyone how to access the JpaEntityManager from Seam or
> > >> >> configure Seam
> > >> >> to use the JpaEntityManager instead of EntityManagerProxy?
> > >> >>
> > >> >> --
> > >> >> Kind regards,
> > >> >> Mathias
> > >> >>
> > >> >> _______________________________________________
> > >> >> eclipselink-users mailing list
> > >> >> eclipselink-users@xxxxxxxxxxx
> > >> >> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> > >> >
> > >> > _______________________________________________
> > >> > eclipselink-users mailing list
> > >> > eclipselink-users@xxxxxxxxxxx
> > >> > https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> > >> >
> > >> _______________________________________________
> > >> eclipselink-users mailing list
> > >> eclipselink-users@xxxxxxxxxxx
> > >> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> > >
> > > _______________________________________________
> > > eclipselink-users mailing list
> > > eclipselink-users@xxxxxxxxxxx
> > > https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> > >
> > _______________________________________________
> > eclipselink-users mailing list
> > eclipselink-users@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> 
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top