[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - ERROR: duplicate key violates unique constraint
vivekmk2006
do-not-reply at jboss.com
Thu Jul 24 01:58:29 EDT 2008
Hi all,
I am trying to execute the bellow code,
private boolean isUserNameExist(){
Users users = getInstance();
String qry = "from Users where userName=:userName AND tenantId =:tenantId";
Query query = entityManager.createQuery(qry);
query.setParameter("userName",users.getUserName()).
setParameter("tenantId", users.getTenantId());
List lst =query.getResultList();
return lst.size() > 0 ? true : false;
}
but i am getting an entirely different exception like bellow.The exception is throwing at "List lst =query.getResultList(); " .
11:22:54,328 ERROR [JDBCExceptionReporter] ERROR: duplicate key violates unique constraint "ad_users_u2"
11:22:54,328 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
Can anybody can help me to fix it.
Thanks in advance
vivek
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4166302#4166302
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4166302
More information about the jboss-user
mailing list