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;
Boolean incremental;
// setter and getter
}
What I want to achieve is, whenever the new service object I want to save has the same name and owner(no matter if the data field incremental are the same or not) as any of the existing one in the database, 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?