openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig L Russell <Craig.Russ...@Sun.COM>
Subject Re: Should UserTransaction Work?
Date Mon, 01 Jan 2007 21:46:38 GMT
Hi Don,

The short answer is yes, UserTransaction is supposed to work.

On Jan 1, 2007, at 11:52 AM, Don Brady wrote:

> I cannot get UserTransaction to work.
>
> Nothing happens when I commit.

Is the symptom that the commit succeeds but there is no change in the  
database?

>
> This consists of:
>
> - Using a JTA datasource
> - specifying Bean Managed Transaction rather then CMT on the  
> enclosing session Bean.
> - looking up a UserTransaction with:
>     UserTransaction userTran = (UserTransaction) initCtx
>                .lookup("java:comp/UserTransaction");
>
> then doing a begin on it, some entity lookup and changes, and a  
> commit.

Is the EntityManagerFactory (PersistenceUnit) also declared as JTA,  
in addition to the DataSource that it uses? Both need to be JTA-enabled.

>
> Could anyone tell me if this should work?
> This is under WebSphere 6.1.
>
> As background, I am able to get a JTA data source to work fine if I  
> use Container Managed Transactions rather than BMT.  The problem  
> with that approach for me is that I am calling the session Bean as  
> a web-service-enable endpoint.  If I leave committing the  
> transaction entirely to JTA, the commit  is done after all of my  
> web service code has exited and any errors are thrown as soap  
> faults.   I want to be able to catch the error and analyze it  
> before returning from the web service.  I can also do this fine  
> with Resource Local Transactions but then I do not get the benefits  
> of a JTA datasource managed by WebSphere.

And the possibility of using other transactional resources as well.
>
> So I am trying to use JTA with BMT which I believe would allow me  
> to catch errors on commit.

Right, this is a good pattern to use in order to wrap database errors  
with your own (presumably more user-friendly) exceptions.

Craig
>
> If this is too much of  a user question for this list, please let  
> me know.....
>
> Thanks!
>
> Don
>
>
>
>
>
>
>
>

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Mime
View raw message