This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Hibernate: unique leads to exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate: unique leads to exception" Watch "Hibernate: unique leads to exception" New topic
Author

Hibernate: unique leads to exception

Kata Franciscan
Greenhorn

Joined: Jul 24, 2008
Posts: 3
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

Joined: Oct 22, 2008
Posts: 62
You are not doing anything wrong. That's how it's suppose to work.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate: unique leads to exception
 
Similar Threads
SQLGrammarException using Hibernate + Embedded Derby
Could not synchronize database state with session Unexpected row count: 0 expected: 1
Problem persisting through Spring/Hibernate project
Issue in inserting into DB using Hibernate, Spring
unique key hibernate exception