avoid duplication with auto increment key in Hibernate
Posted
by Lily
on Stack Overflow
See other posts from Stack Overflow
or by Lily
Published on 2010-03-24T18:52:50Z
Indexed on
2010/03/24
22:43 UTC
Read the original article
Hit count: 234
I am trying to use Hibernate to auto increment the id, however, I try to avoid duplication.
class Service
{
Long id; // auto increment
String name;
String owner;
// setter and getter
}
What I want to achieve is, whenever name and owner are the same, it will be a duplicated entry. In this case, I don't want to add another entry into the Database anymore. How to revise the hbm.xml files to avoid this issue?
© Stack Overflow or respective owner