MyEclipse Forums
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
CFaisal
Post subject: Could not execute JDBC batch update  PostPosted: May 15, 2008 - 01:54 PM



Joined: May 15, 2008
Posts: 1

Hi ALL,

I run the Qtuickstart Hibernate Introduction tutorial successfully. But when i tried to run again, it started giving this error below.

Please help how to resolve this issue.


log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" 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)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.myeclipse.hibernate.HibernateExample.addUser(HibernateExample.java:41)
at com.myeclipse.hibernate.HibernateExample.main(HibernateExample.java:12)
Caused by: java.sql.BatchUpdateException: Duplicate entry '1' for key 1
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:657)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
... 9 more
 
 View user's profile Send private message  
Reply with quote Back to top
support-nipun
Post subject: RE: Could not execute JDBC batch update  PostPosted: May 15, 2008 - 04:33 PM
Registered Member
Registered Member


Joined: Apr 18, 2007
Posts: 8012

Can you go to MyEclipse > Installation Summary > Installation Details and paste the information here for me.

Can you switch to a new workspace and test this project again. Do you still face the same issue ?

_________________
Nipun
MyEclipse Support
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
Niloofar
Post subject:   PostPosted: Dec 20, 2009 - 02:36 PM



Joined: Dec 20, 2009
Posts: 1

It may occur because columns in the your db which refer to particular entity does not match with that in code.
you can insert this line in your hibernate configuration file:
<property name="show_sql">true</property>
to see what hibernate really does.
 
 View user's profile Send private message  
Reply with quote Back to top
support-nipun
Post subject:   PostPosted: Dec 21, 2009 - 04:39 PM
Registered Member
Registered Member


Joined: Apr 18, 2007
Posts: 8012

Thank you for posting this information.

_________________
Nipun
MyEclipse Support
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
amir55
Post subject: Duplicate entry '1' for key 'PRIMARY' error  PostPosted: Mar 12, 2010 - 09:29 AM
Registered Member
Registered Member


Joined: Oct 15, 2005
Posts: 212

Hi dear

I have the same problem which is so odd as my simple appl worked in package one so when I just copy the same code into package two after of course changing the package references only.

MyEclipse could not allow updating. sometimes I need to drop the database and recreate it and sometimes I use new database which is a bug I suppose but this time the error stays constant.

I got this error

Exception in thread "main" 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)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:92)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:87)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2232)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2660)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:56)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at common.HibernateDAOImpl.update(HibernateDAOImpl.java:232)
at common.SpringDAOManager.update(SpringDAOManager.java:66)
at common.SpringDAOManager$$FastClassByCGLIB$$61cd036b.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:624)
at common.SpringDAOManager$$EnhancerByCGLIB$$8320981b.update(<generated>)
at common.ClientHandler.update(ClientHandler.java:91)
at one_to_many_bi.Client.main(Client.java:23)
Caused by: java.sql.BatchUpdateException: Duplicate entry '1' for key 'PRIMARY'
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:657)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 19 more


yours

Amir
 
 View user's profile Send private message  
Reply with quote Back to top
dakshinn
Post subject:   PostPosted: Feb 03, 2011 - 02:48 PM



Joined: Feb 03, 2011
Posts: 1

"Duplicate entry '1' for key 'PRIMARY' " - Check you are trying to insert duplicate value for the primary key value.
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits