This content has been marked as final.
Show 3 replies
-
1. Re: Help needed with JPA please...
qwertywin Jan 28, 2009 3:32 AM (in response to paulmkeogh)@Id @GeneratedValue(strategy = GenerationType.AUTO public long getId() { return this.id; } public void setId(long id) { this.id = id; }
should work
-
2. Re: Help needed with JPA please...
chawax Jan 28, 2009 10:50 AM (in response to paulmkeogh)I used TABLE generation type too and it works fine for me. One difference I see is that you didn't add @javax.persistence.Id annotation to your getId() method. Maybe you should try this ;)
-
3. Re: Help needed with JPA please...
paulmkeogh Jan 28, 2009 10:43 PM (in response to paulmkeogh)
Thanks for the replies but I think the issue is a bit more complex.
@Id in this case is in fact part of a composite primary key.
And, according to this post on the Hibernate forum, you cannot use @GeneratedValue in an EmbeddedId class (the composite primary key).
See http://forums.hibernate.org/viewtopic.php?p=2393944&sid=57b20ef2c7de6f6bcba632130987bc22
So I guess its back to java.util.random and rolling my own IDs :-(