glassfish_at_javadesktop.org wrote:
> Tried to use SEQUENCE but then no sequence per table is automatically
> created. I think one has to specify
>
> @SequenceGenerator(name="InvSeq",sequenceName="INV_SEQ",
> allocationSize=5)
We tried that and couldn't get it to work :(
> for each id attribute separately - no sensible auto-generation
> (sequence names) like with IDENTITY :(.
We define the uid as SERIAL PRIMARY KEY, then do this:
@Id @GeneratedValue(strategy=GenerationType.SEQUENCE)
@Column(name = "uid", nullable = false)
private Integer uid;
Postgres generates the sequence (tablename_uid_seq) when the table is
created, and we are getting auto-incremented values in the uid field
when we persist an object.
http://www.postgresql.org/docs/8.2/interactive/datatype-numeric.html#DATATYPE-SERIAL
--
____________________________________________________________
Glenn Holmer gholmer_at_weycogroup.com
Software Engineer phone: 414-908-1809
Weyco Group, Inc. fax: 414-908-1601