You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Ba...@ggrz-hagen.nrw.de on 2008/02/13 14:24:45 UTC
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,....
Re: Primary key field generation with postgres
Posted by Patrick Linskey <pl...@gmail.com>.
Were you getting similar errors when attempting to do schema generation?
Also, what happens if you set the openjpa.jdbc.Schema property to 'ves'?
-Patrick
On 2/13/08, Baumhof@ggrz-hagen.nrw.de <Ba...@ggrz-hagen.nrw.de> wrote:
> 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,....
>
>
>
>
>
>
--
Patrick Linskey
202 669 5907