How to create a Serial id field in postgres using Ebean?

440 views
Skip to first unread message

jmunning

unread,
Apr 30, 2012, 2:36:26 PM4/30/12
to eb...@googlegroups.com
Is there an annotation to put on an id field (or some other way) that will cause the ddl to create a postgres id field that uses a sequence?

I've tried using @GeneratedValue with different strategy types but no effect on postgres tables.

What I would like to end up with is SQl that looks like:
CREATE TABLE tablename (
    colname SERIAL PRIMARY KEY
);

Rob Bygrave

unread,
May 2, 2012, 11:07:37 PM5/2/12
to eb...@googlegroups.com
No there is not. That would be an enhancement request.

http://www.postgresql.org/docs/8.1/static/datatype.html#DATATYPE-SERIAL

I presume you want to use Serial in a 'auto increment' type of fashion and hence use getGeneratedKeys?

WeAreTheSmallAxe

unread,
May 22, 2012, 6:04:33 PM5/22/12
to eb...@googlegroups.com
I have an Insert statement I'm running as 

Ebean.createSqlUpdate(query);
int rowsInserted = Ebean.execute(sqlUpdate);

It is a group by that inserts multiple rows and it fails if the id field is not marked as SERIAL.

Rob Bygrave

unread,
Jun 14, 2012, 10:54:37 PM6/14/12
to eb...@googlegroups.com

Logged as http://www.avaje.org/bugdetail-406.html - BUG 406 : ENH: Add support for Postgres Serial type

Reply all
Reply to author
Forward
0 new messages