You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by ubiteck <su...@gmail.com> on 2012/11/08 10:56:09 UTC

Re: Verified database matrix (was: PostgreSQL 9.1 [Error :current transaction is aborted])

I found the issue. The problem is related to the use of the underscore in
table name. Let's imagine you have an entity called *SubscriptionEvent *with
an auto generated field called *id* (/GenerationType.IDENTITY/). 
You want OpenJPA to create a table named SUBSCRIPTION_EVENT by using the
following annotation to please you DBA with is favorite naming convention :  
   @Table(name="SUBSCRIPTION_EVENT") 
The problem occurs when the class PostgresDictionary try to determine
whether a sequence is owned by the database using the method is
/isOwnedSequence/. This method use another method called *buildNames* to
define what is the table name and the column name to provide the parameters
to the sql statement : 
SELECT pg_get_serial_sequence(?, ?) 
The argument provided to *buildNames* according to the name provided in the
annotation @Table and the identity field is : "subscription_event_id".
BuildNames split this string using the underscore as separator interpreting
this :
*   Table name : *	subscription 
*  Column name :*	event_id

instead of 
*   Table name :*	 subscription_event 
*Column name :*	id
As a workaround you have to remove the underscore in you table or field
name. But it is in my opinion a bug to rely on the underscore to split the
table from the column name.   
  



--
View this message in context: http://openjpa.208410.n2.nabble.com/PostgreSQL-9-1-Error-current-transaction-is-aborted-tp7580209p7581664.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Verified database matrix (was: PostgreSQL 9.1 [Error :current transaction is aborted])

Posted by ubiteck <su...@gmail.com>.
Kevin,
As recommended I created a JIRA  OPENJPA-2297
<https://issues.apache.org/jira/browse/OPENJPA-2297>  
I'm using PostgreSQL 8.4 with Geronimo 3.0, JDK 1.6 Sébastien



--
View this message in context: http://openjpa.208410.n2.nabble.com/PostgreSQL-9-1-Error-current-transaction-is-aborted-tp7580209p7581684.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Verified database matrix (was: PostgreSQL 9.1 [Error :current transaction is aborted])

Posted by Kevin Sutter <kw...@gmail.com>.
Hi sursini,
Excellent debug work!  I took a look at the code and you are right.  The
buildNames() method is using the underscore as the separator and causing
the issue.  Can you create a JIRA for this issue?  Thank you.

Just curious, what type of runtime environment are you using OpenJPA and
Postgres?  JSE?  App Server?  Which one?  Just a random survey...  :-)
Thanks!

Kevin

On Thu, Nov 8, 2012 at 3:56 AM, ubiteck <su...@gmail.com> wrote:

> I found the issue. The problem is related to the use of the underscore in
> table name. Let's imagine you have an entity called *SubscriptionEvent
> *with
> an auto generated field called *id* (/GenerationType.IDENTITY/).
> You want OpenJPA to create a table named SUBSCRIPTION_EVENT by using the
> following annotation to please you DBA with is favorite naming convention :
>    @Table(name="SUBSCRIPTION_EVENT")
> The problem occurs when the class PostgresDictionary try to determine
> whether a sequence is owned by the database using the method is
> /isOwnedSequence/. This method use another method called *buildNames* to
> define what is the table name and the column name to provide the parameters
> to the sql statement :
> SELECT pg_get_serial_sequence(?, ?)
> The argument provided to *buildNames* according to the name provided in the
> annotation @Table and the identity field is : "subscription_event_id".
> BuildNames split this string using the underscore as separator interpreting
> this :
> *   Table name : *      subscription
> *  Column name :*       event_id
>
> instead of
> *   Table name :*        subscription_event
> *Column name :* id
> As a workaround you have to remove the underscore in you table or field
> name. But it is in my opinion a bug to rely on the underscore to split the
> table from the column name.
>
>
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/PostgreSQL-9-1-Error-current-transaction-is-aborted-tp7580209p7581664.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.