Nommi wrote:
bt still different question why it is a limitation in hibernate that we only set the Sequence only on Primart key... is there no alternative abt it... there are many situation in which we wanna use sequence on any field in Db so if use Hibernate than thats mean stuck on it....
Don't know, but you can always do this in the database i guess.
Add a trigger that works on insert.
Maybe it's considered questionable design if you have another (unique) value in the same table thats assigned by sequence?
Because if you have one unique value you wouldn't need the other as primary key in the first place...
Nommi wrote:
if i simply run query and wanna add user than DB sequence work and increment bt when i try to save using Hibernate session.save(obj); than my filed value set to be null and not increment..
Code:
User user = new User();
user.setName("Myname");
session.save(user);
works fine for me with ID and GeneratedValue from Sequence