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:

        @Id
  |     @Column(name = "id", unique = true, nullable = false)
  |     @SequenceGenerator(name="identifier", sequenceName="ppl_id_seq", 
allocationSize=1)
  |     @GeneratedValue(strategy=GenerationType.SEQUENCE, 
generator="identifier")
  |     @NotNull
  |     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
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to