• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate: unique leads to exception

 
Kata Franciscan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a DB table containing names which should be unique. My name class looks (partly) like this:


However, if I now try to insert a new name into the db:
HibernateTemplate org.springframework.orm.hibernate3.support.HibernateDaoSupport.getHibernateTemplate().saveOrUpdate(nameObject);

I see an exception if the name is already in the database:

Can anyone here tell me what is wrong? I am a newbie containing Annotations, Hibernate, PostgreSQL and Spring, so the problem might be anywhere ...
 
Emmanuel Bernard
author
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are not doing anything wrong. That's how it's suppose to work.
 
Of course, I found a very beautiful couch. Definitely. And this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!