1. Hibernate: unique leads to exception coderanch.com
Hi, I have a DB table containing names which should be unique. My name class looks (partly) like this: @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; @Column(unique=true, nullable=false) private String name; 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:08/12/09 17:25:37 ERROR util.JDBCExceptionReporter: ERROR: duplicate ...
2. will hibernate generate unique exception code forum.hibernate.org
will i get a unique exception code generated by hibernate in case of any database exception for example if it is a constraint violation exception if i am getting an error code along with the error message i can identify what the error is and display it to users in a userfriendly way. thanks Sharon
3. to catch the Unique contraint violation Exception forum.hibernate.org
You're catching hibernate's ConstraintViolationException, but getSQLState() is returning null? Odd. What is getSQLException() returning? If that's not null, you can use getSQLException().getSQLState(). If that doesn't work, you could put a breakpoint in SQLStateConverter and see what's happening. You may have to extend your Dialect, if the SQLException is being thrown away due to being unparsable in some way.
4. Duplicate unique="true" causing exception forum.hibernate.org
Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Hibernate version:2.0 Mapping documents: