[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Transaction issue with separate JBoss jars

dtseiler do-not-reply at jboss.com
Mon Feb 12 15:08:38 EST 2007

Recently we have tried to separate our EJB Project out into two parts.
One project to handle all of our persistence and another to handle all
of our service's.   The persistence project was set up to serve out
entity objects back through a DAO service.  This way our Service project
can just call into our DAO services and retrieve the information that
they would need and allowing for a nice split between two different
types of projects.  However, in the process of separating these projects
out we hit some issues with the transaction manager not flushing upon
the call of the flush command. 

The flush command is something we greatly rely on as a means to make
sure our data is persisted underneath the proper user in the database
through contexts. It is also the means in which we can allow support of
oracle proxy connections. We achieved this by having a
PrepareDatabaseConnection AOP method; which is executed before and after
a method is called. Allowing for us to set the database context after
the transaction is started and to close the database context before the
transaction ends.  Ideally we would have liked to hook it directly onto
the begging and end of the transaction but we couldn't find a great way
to do so.  So instead on every one of our services and DAO work we added
the PrepareDatabaseConnection interceptor to properly set our database
context or to configure the connection as a proxy connection.   In a
single jar this functionality works great.  However, in separate jars we
start to see issues with the database context not being properly set,
which leads to issues with auditing what users changed the data in the

In a single jar the contents flush upon my call to the entity manager to
commit / update the information.  However, when these are separate jars
the flush doesn't occur until the transaction manager tells it to flush
and close the transaction.  At which point in time the database context
has already been unset leaving no record of which user was actually
using that connection from the connection pool.

Why is it when we move the database code out to a separate jar the
entity managers flush doesn't actually flush the information when it was
requested to?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4015369#4015369

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4015369

More information about the jboss-user mailing list