You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by femski <hy...@yahoo.com> on 2007/06/27 11:51:11 UTC
Problem with generating IDs from table
Folks !
I am using following table-generator to generate primary key IDs:
<table-generator name="ObjId" table="ObjId_Gen" pk-column-name="seq_name"
value-column-name="value" pk-column-value="ObjId"/>
Then I use it in usual way:
@Id @GeneratedValue(strategy=GenerationType.TABLE,generator="ObjId")
Problem is OpenJPA is looking for column "value0" in the table. Toplink
correctly generated ID from "value" column.
Is this a bug or am I missing something ?
thanks,
-Sanjay
--
View this message in context: http://www.nabble.com/Problem-with-generating-IDs-from-table-tf3987295.html#a11321459
Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: Problem with generating IDs from table
Posted by femski <hy...@yahoo.com>.
I changed the SequenceColumn to "seq_val" from "value" which you said was a
reserved word and it worked !
thanks,
--
View this message in context: http://www.nabble.com/Problem-with-generating-IDs-from-table-tf3987295.html#a11437385
Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: Problem with generating IDs from table
Posted by Marc Prud'hommeaux <mp...@apache.org>.
Sanjay-
If you declare the generator as an annotation rather than in the
orm.xml file, does it change anything? E.g.:
@Id @GeneratedValue
(strategy=GenerationType.TABLE,generator="ObjId")
@SequenceGenerator(name="ObjId" sequence="table
(Table=ObjId_Gen,SequenceColumn=value,PrimaryKeyColumn=ObjId)")
I don't see why that would change it, but it's worth a shot.
FTR, OpenJPA is probably tacking on a "0" to the end of the column
name because it deems "value" to be a reserved word in SQL. However,
when you manually specify the name of the column, I thought that that
always overrode the suffixing of the name.
On Jun 27, 2007, at 2:51 AM, femski wrote:
>
> Folks !
>
> I am using following table-generator to generate primary key IDs:
>
> <table-generator name="ObjId" table="ObjId_Gen" pk-column-
> name="seq_name"
> value-column-name="value" pk-column-value="ObjId"/>
>
> Then I use it in usual way:
>
> @Id @GeneratedValue
> (strategy=GenerationType.TABLE,generator="ObjId")
>
> Problem is OpenJPA is looking for column "value0" in the table.
> Toplink
> correctly generated ID from "value" column.
>
> Is this a bug or am I missing something ?
>
> thanks,
>
> -Sanjay
> --
> View this message in context: http://www.nabble.com/Problem-with-
> generating-IDs-from-table-tf3987295.html#a11321459
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>