-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: duplicate key violates unique constraint
PostPosted: Thu Jul 24, 2008 2:44 am 
Newbie

Joined: Tue Jul 15, 2008 5:30 am
Posts: 7
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(); ". One more thing i have an objec 'Users' in scope.

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.