You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by "roger.keays" <ro...@ninthavenue.com.au> on 2008/03/27 11:51:36 UTC

RE: Primary key field generation with postgres



Marc LaPierre wrote:
> 
> It seems like JPA isn't finding your sequence in the ves schema.
> 
> Are you sure that your sequence exists in Postgres?
> Are you able to run "select currval('user_id_seq')" from the sql
> console?
> 

Was this ever resolved? In this case SELECT currval('user_id_seq'); should
*not* execute correctly. The correct query is SELECT
currval('schemaname.user_id_seq'); and this is what OpenJPA should be
executing.

I have the same problem. 



> 
> Marc
> 
> 
> -----Original Message-----
> From: Baumhof@ggrz-hagen.nrw.de [mailto:Baumhof@ggrz-hagen.nrw.de]
> Sent: Wednesday, February 13, 2008 8:25 AM
> To: users@openjpa.apache.org
> Subject: Primary key field generation with postgres
> 
> I use Postgres 8.2 with jdbc Type 3 driver.
> 
> I have got the following table definition:
> 
> 
> 
> create table ves.user
> 
> (id                    serial    not null,
> 
>  user                 varchar(20) not null,
> 
>  password         varchar(20) not null,
> 
>  constraint pk_ves_user primary key(id)
> 
> );
> 
> 
> 
> 
> 
> My PAO Class looks like:
> 
> 
> 
> @Entity
> 
> @Table(schema="ves", name="user")
> 
> public class UserPAO implements Serializable {
> 
>             @Id
> 
>             @GeneratedValue(strategy=IDENTITY)
> 
>             @Column(insertable=false, updatable = false)
> 
>             private long id;
> 
>             ....
> 
> 
> 
> Trying to insert a new user results in an persistence exception: The
> invalid statement is reported
> 
> As: select currval('user_id_seq')
> 
> 
> 
> But the table is in the schema "ves", so the correct name of the
> sequence is ves.user_id_seq.
> 
> If I put the table into the public schema, and omit the schema="ves"
> statement in the @Table
> 
> annotation, all works.
> 
> 
> 
> How can I use automatic key generation with Postgres without putting the
> table into the public schema??
> 
> Table generation and all other things did not work.
> 
> 
> 
> Thanks in advance,....
> 
> 
> 
> 
> ---------------------------------------------------------------------
> This transmission (including any attachments) may contain confidential
> information, privileged material (including material protected by the
> solicitor-client or other applicable privileges), or constitute non-public
> information. Any use of this information by anyone other than the intended
> recipient is prohibited. If you have received this transmission in error,
> please immediately reply to the sender and delete this information from
> your system. Use, dissemination, distribution, or reproduction of this
> transmission by unintended recipients is not authorized and may be
> unlawful.
> 
> 

-- 
View this message in context: http://www.nabble.com/Primary-key-field-generation-with-postgres-tp15460899p16324003.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.