You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by David Jencks <da...@yahoo.com> on 2006/10/03 10:35:26 UTC

Problem with sequence trying to commit inside a JTA tx

I'm trying to set up a really simple example inside geronimo with  
container managed transactions/persistence contexts.  When I create  
and persist an object the TableJDBCSeq is trying to commit the  
connection before closing it: since it's in a JTA tx of course this  
fails.

It looks like nothing is setting type on the AbstractJDBCSeq and I  
can't detect any use of SequenceMetadata which is the only place I  
can find that has code to set the type on the seq.

What am I doing wrong?  Is there some other code that could set the  
type on the sequence?  Is there some way to make SequenceMetadata  
kick in or even set _type on SequenceMetadata?

Code from AbstractJDBCSeq:

     protected void closeConnection(Connection conn) {
         if (conn == null)
             return;

         try {
             if (type != TYPE_TRANSACTIONAL && type != TYPE_CONTIGUOUS)
                 conn.commit();
         } catch (SQLException se) {
             throw SQLExceptions.getStore(se);
         } finally {
             try { conn.close(); } catch (SQLException se) {}
         }
     }


I think that since I'm in a JTA tx type ought to be  
TYPE_TRANSACTIONAL, is this reasonable?

thanks
david jencks


Re: Problem with sequence trying to commit inside a JTA tx

Posted by Michael Dick <mi...@gmail.com>.
On 10/4/06, Patrick Linskey <pl...@bea.com> wrote:
>
> > Following the advice there (and elsewhere) I managed to get my
> > example working!!! The main step appears to be including a non-jta
> > datasource.
>
> Cool.
>
> > I'm still unable to figure out how to get the tables auto-created.
> > Putting properties in persistence.xml or feeding them to
> > persistenceProvider.createContainerEntityManagerFactory doesn't seem
> > to have any discernable effect.  Any advice on how to figure
> > out what
> > is going on?
>
> Have you set the SynchronizeMappings property?
>
> > Is there an m2 plugin for running the tools for e.g. creating
> > tables,
> > db scripts, etc?
>
> Not currently, no.


You can probably use the ant-maven plugin to run the mapping tool ant task,
or to invoke the mapping tool class directly.  It can be tricky to get the
classpath set up properly (http://issues.apache.org/jira/browse/OPENJPA-8)
but those issues should be ironed out by now.

"Native" m2 plugins sound like a good idea though.

> Also, it appears that the documentation generally says
> > property names
> > are e.g. openjpa.jdbc.kernel.PropertyName whereas there is some
> > indication in the code that they are the more correct
> > org.apache.openjpa.jdbc.kernel.PropertyName.  Which is right?  If
> > they are actually as per the docs shouldn't they be changed pronto?
>
> Actually, generally they're of the form openjpa.PropertyName for
> general-purpose (non-JDBC-specific) properties, and
> openjpa.jdbc.PropertyName for JDBC-specific stuff.
>
> Personally, I think that adding the org.apache. to the beginning is more
> noisy than anything else. But obviously, it'd be possible to do so.


I agree about the noise. Adding another prefix seems pretty easy to do, but
it might just make things more confusing to accept openjpa.xxx and
org.apache.openjpa.xxxx for the same property.


> -Patrick
> _______________________________________________________________________
> Notice:  This email message, together with any attachments, may contain
> information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
> entities,  that may be confidential,  proprietary,  copyrighted  and/or
> legally privileged, and is intended solely for the use of the individual
> or entity named in this message. If you are not the intended recipient,
> and have received this message in error, please immediately return this
> by email and then delete it.
>



-- 
-Michael Dick

Re: Problem with sequence trying to commit inside a JTA tx

Posted by Abe White <aw...@bea.com>.
> With regard to your JIRA suggestion, are you saying there is no way  
> using these properties to choose between e.g. TableJDBCSeq and  
> ClassTableJDBCSeq or the oracle sequence sequence?  I'm happy to  
> file lots of jiras but I'd prefer to be a little more sure of what  
> the problem is :-)

No, I was trying to say that there's no way to set whether the  
sequence is transactional, nontransactional, contiguous.  A  
transacitonal/contiguous sequence won't need a non-jta-data-source.
_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

RE: Problem with sequence trying to commit inside a JTA tx

Posted by Patrick Linskey <pl...@bea.com>.
> Following the advice there (and elsewhere) I managed to get my  
> example working!!! The main step appears to be including a non-jta  
> datasource.

Cool.

> I'm still unable to figure out how to get the tables auto-created.   
> Putting properties in persistence.xml or feeding them to  
> persistenceProvider.createContainerEntityManagerFactory doesn't seem  
> to have any discernable effect.  Any advice on how to figure 
> out what  
> is going on?

Have you set the SynchronizeMappings property?

> Is there an m2 plugin for running the tools for e.g. creating 
> tables,  
> db scripts, etc?

Not currently, no.

> Also, it appears that the documentation generally says 
> property names  
> are e.g. openjpa.jdbc.kernel.PropertyName whereas there is some  
> indication in the code that they are the more correct  
> org.apache.openjpa.jdbc.kernel.PropertyName.  Which is right?  If  
> they are actually as per the docs shouldn't they be changed pronto?

Actually, generally they're of the form openjpa.PropertyName for
general-purpose (non-JDBC-specific) properties, and
openjpa.jdbc.PropertyName for JDBC-specific stuff.

Personally, I think that adding the org.apache. to the beginning is more
noisy than anything else. But obviously, it'd be possible to do so.

-Patrick
_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

Re: Problem with sequence trying to commit inside a JTA tx

Posted by David Jencks <da...@yahoo.com>.
On Oct 3, 2006, at 9:54 AM, Abe White wrote:

>> I'm trying to set up a really simple example inside geronimo with  
>> container managed transactions/persistence contexts.  When I  
>> create and persist an object the TableJDBCSeq is trying to commit  
>> the connection before closing it: since it's in a JTA tx of course  
>> this fails.
>
> http://people.apache.org/~mprudhom/openjpa/site/openjpa-project/ 
> manual/ 
> ref_guide_dbsetup_thirdparty.html#ref_guide_dbsetup_thirdparty_enlist
>
> See above docs on managed and XA datasources.  And right now we  
> unfortunately don't have a way to set the seq type (transactional,  
> etc) through JPA.  If you'd like to take the initiative to make a  
> JIRA report on it, that'd be great.  I'll comment on the report you  
> create with the steps necessary to expose this functionality to the  
> JPA layer.

Following the advice there (and elsewhere) I managed to get my  
example working!!! The main step appears to be including a non-jta  
datasource.

I'm still unable to figure out how to get the tables auto-created.   
Putting properties in persistence.xml or feeding them to  
persistenceProvider.createContainerEntityManagerFactory doesn't seem  
to have any discernable effect.  Any advice on how to figure out what  
is going on?

Is there an m2 plugin for running the tools for e.g. creating tables,  
db scripts, etc?

With regard to your JIRA suggestion, are you saying there is no way  
using these properties to choose between e.g. TableJDBCSeq and  
ClassTableJDBCSeq or the oracle sequence sequence?  I'm happy to file  
lots of jiras but I'd prefer to be a little more sure of what the  
problem is :-)


Also, it appears that the documentation generally says property names  
are e.g. openjpa.jdbc.kernel.PropertyName whereas there is some  
indication in the code that they are the more correct  
org.apache.openjpa.jdbc.kernel.PropertyName.  Which is right?  If  
they are actually as per the docs shouldn't they be changed pronto?

thanks!
david jencks

> ______________________________________________________________________ 
> _
> Notice:  This email message, together with any attachments, may  
> contain
> information  of  BEA Systems,  Inc.,  its subsidiaries  and   
> affiliated
> entities,  that may be confidential,  proprietary,  copyrighted   
> and/or
> legally privileged, and is intended solely for the use of the  
> individual
> or entity named in this message. If you are not the intended  
> recipient,
> and have received this message in error, please immediately return  
> this
> by email and then delete it.


Re: Problem with sequence trying to commit inside a JTA tx

Posted by Abe White <aw...@bea.com>.
> I'm trying to set up a really simple example inside geronimo with  
> container managed transactions/persistence contexts.  When I create  
> and persist an object the TableJDBCSeq is trying to commit the  
> connection before closing it: since it's in a JTA tx of course this  
> fails.

http://people.apache.org/~mprudhom/openjpa/site/openjpa-project/ 
manual/ 
ref_guide_dbsetup_thirdparty.html#ref_guide_dbsetup_thirdparty_enlist

See above docs on managed and XA datasources.  And right now we  
unfortunately don't have a way to set the seq type (transactional,  
etc) through JPA.  If you'd like to take the initiative to make a  
JIRA report on it, that'd be great.  I'll comment on the report you  
create with the steps necessary to expose this functionality to the  
JPA layer.
_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.