[jboss-user] [JBoss Seam] - Re: How to use @Id @GeneratedValue(strategy=GenerationType.A
do-not-reply at jboss.com
Thu Mar 1 13:26:21 EST 2007
In Enterprise JavaBeans 3.0 (O'Reilly 2006) it states "The AUTO strategy tells the persistence provider that you are allowing it to generate the key for you" (page 94).
I don't specifically know the Hibernate implements this feature, but might I suggest that you utilize the features of your database to create primary keys instead.
With Postgresql you could use a mapping like this:
| @Column(name = "id", unique = true, nullable = false)
| @SequenceGenerator(name="identifier", sequenceName="ppl_id_seq", allocationSize=1)
| @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="identifier")
| public int getId()
| return this.id;
In this manner Hibernate would assign primary keys from the Postgresql sequence rather than internally. This would allow Hibernate to "play nicely" with other database users.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024423#4024423
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4024423
More information about the jboss-user