I have created a table in database using hibernate and one of the attribute(username) is a primary key.So when i try to insert duplicate values in the username i'm getting the following exception.Now i have to handle this exception so as to prompt the user as "username already exists".
22462 [http-8080-2] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: null 22462 [http-8080-2] ERROR org.hibernate.util.JDBCExceptionReporter - failed batch 22462 [http-8080-2] ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session