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.  [ 3 posts ] 
Author Message
 Post subject: java.sql.BatchUpdateException: Duplicate entry '140-4883' fo
PostPosted: Wed Jul 09, 2008 3:20 am 
Newbie

Joined: Wed Jul 09, 2008 2:43 am
Posts: 2
Dear All,

I am facing problem when insort in to database. Please Provide me some solution.

My flow of prokect is: I am sending queryresponse to xml server and retrive the queryresponse and populate the database.

When I run my application it showing error like:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00:31:19,105 DEBUG BasicResourcePool:1159 - trace com.mchange.v2.resourcepool.BasicResourcePool@60a77c [managed: 5, unused: 1, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@1125fac)
00:31:19,105 DEBUG JDBCTransaction:59 - current autocommit status: false
00:31:19,105 DEBUG JDBCTransaction:103 - commit
00:31:19,105 DEBUG SQL:346 - [b]insert into hardware_system_configuration.filesystems (filesystem_name, storage_pools, storage_system_id, volume_id, contains_slices, internal_use, filesystem_type, cworm_state, celerra_system_record_id, filesystem_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)[/b]
Hibernate: [b]insert into hardware_system_configuration.filesystems (filesystem_name, storage_pools, storage_system_id, volume_id, contains_slices, internal_use, filesystem_type, cworm_state, celerra_system_record_id, filesystem_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)[/b]
00:31:19,105 DEBUG GooGooStatementCache:381 - cxnStmtMgr.statementSet( com.mysql.jdbc.Connection@b5df86 ).size(): 3
00:31:19,105 DEBUG GooGooStatementCache:117 - checkoutStatement: com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 10; checked out: 1; num connections: 5; num keys: 10
00:31:19,121 DEBUG NewPooledConnection:304 - com.mchange.v2.c3p0.impl.NewPooledConnection@a826f5 handling a throwable.
[b]java.sql.BatchUpdateException: Duplicate entry '140-4883' for key 1[/b]
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:647)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
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.emc.nas.dvt.xml.api.database.FilesystemsTable.addRowToTable(FilesystemsTable.java:110)
at com.emc.nas.dvt.xml.api.collect.CollectCelerraConfigurationInformation.populateDBFromQueryResponse(CollectCelerraConfigurationInformation.java:247)
at com.emc.nas.dvt.xml.api.execute.ConfigurationCapture.main(ConfigurationCapture.java:228)
00:31:19,121 DEBUG SqlUtils:83 - Attempted to convert SQLException to SQLException. Leaving it alone. [SQLState: 23000; errorCode: 1062]
java.sql.BatchUpdateException: Duplicate entry '140-4883' for key 1
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:647)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
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.emc.nas.dvt.xml.api.database.FilesystemsTable.addRowToTable(FilesystemsTable.java:110)
at com.emc.nas.dvt.xml.api.collect.CollectCelerraConfigurationInformation.populateDBFromQueryResponse(CollectCelerraConfigurationInformation.java:247)
at com.emc.nas.dvt.xml.api.execute.ConfigurationCapture.main(ConfigurationCapture.java:228)
00:31:19,121 DEBUG DefaultConnectionTester:67 - Testing a Connection in response to an Exception:
java.sql.BatchUpdateException: Duplicate entry '140-4883' for key 1
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:647)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
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.emc.nas.dvt.xml.api.database.FilesystemsTable.addRowToTable(FilesystemsTable.java:110)
at com.emc.nas.dvt.xml.api.collect.CollectCelerraConfigurationInformation.populateDBFromQueryResponse(CollectCelerraConfigurationInformation.java:247)
at com.emc.nas.dvt.xml.api.execute.ConfigurationCapture.main(ConfigurationCapture.java:228)
00:31:19,136 DEBUG GooGooStatementCache:171 - checkinStatement(): com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 10; checked out: 0; num connections: 5; num keys: 10
00:31:19,136 WARN JDBCExceptionReporter:71 - SQL Error: 1062, SQLState: 23000
00:31:19,136 ERROR JDBCExceptionReporter:72 - Duplicate entry '140-4883' for key 1
00:31:19,136 ERROR AbstractFlushingEventListener:300 - 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)
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.emc.nas.dvt.xml.api.database.FilesystemsTable.addRowToTable(FilesystemsTable.java:110)
at com.emc.nas.dvt.xml.api.collect.CollectCelerraConfigurationInformation.populateDBFromQueryResponse(CollectCelerraConfigurationInformation.java:247)
at com.emc.nas.dvt.xml.api.execute.ConfigurationCapture.main(ConfigurationCapture.java:228)
Caused by: java.sql.BatchUpdateException: Duplicate entry '140-4883' for key 1
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:647)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
... 10 more
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.emc.nas.dvt.xml.api.database.FilesystemsTable.addRowToTable(FilesystemsTable.java:110)
at com.emc.nas.dvt.xml.api.collect.CollectCelerraConfigurationInformation.populateDBFromQueryResponse(CollectCelerraConfigurationInformation.java:247)
at com.emc.nas.dvt.xml.api.execute.ConfigurationCapture.main(ConfigurationCapture.java:228)
Caused by: java.sql.BatchUpdateException: Duplicate entry '140-4883' for key 1
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:647)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
... 10 more
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Could you please any one give me some solution.

Thanks,
Manas[/b]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 09, 2008 5:18 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Are you putting entity data in the Session, and then pulling it out later? This can confuse the Hibernate Session, and make the Session think it is being passed new objects, instead of ones that it is already managing. Is that possible?

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: java.sql.BatchUpdateException: Duplicate entry '140-4883' fo
PostPosted: Thu Jul 10, 2008 3:13 am 
Newbie

Joined: Wed Jul 09, 2008 2:43 am
Posts: 2
I have not use any entity data in the Session. Mu HibernateUtil session code is:


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/**
*
*/
package com.emc.nas.dvt.xml.api.collect;





import org.apache.log4j.Logger;
import org.hibernate.*;
import org.hibernate.cfg.Configuration;
import org.hibernate.stat.SessionStatistics;
import org.hibernate.stat.Statistics;



public class HibernateUtility {

private static SessionFactory sessionFactory;

private static SessionFactory dvtsnfs2SessionFactory;

private static Logger logger = Logger.getLogger(CollectCelerraConfigurationInformation.class.getPackage().getName());

static{

//Create a session factory using the defaults in hibernate.cfg.xml
try {

Configuration cfg = new Configuration().configure();

sessionFactory = cfg.buildSessionFactory();

Statistics stats = sessionFactory.getStatistics();

logger.info("Hibernate start Time: " + stats.getStartTime());

logger.info("Hibernate Update count: " + stats.getCollectionUpdateCount());

Session session = sessionFactory.getCurrentSession();

SessionStatistics sessionStats = session.getStatistics();

logger.info("Session Stats: " + sessionStats.getCollectionCount());

} catch (Throwable exception) {

// TODO: handle exception. Log exception
logger.fatal("Initial SessionFactory creation failed." + exception);
throw new ExceptionInInitializerError(exception);

}

//Create a session factory using the defaults in testReport.cfg.xml
/*try {

Configuration cfg = new Configuration().configure("testReport.cfg.xml");

dvtsnfs2SessionFactory = cfg.buildSessionFactory();

Statistics stats = dvtsnfs2SessionFactory.getStatistics();

logger.info("Hibernate start Time to 12.02.133.250: " + stats.getStartTime());

logger.info("Hibernate Update count on 12.02.133.250: " + stats.getCollectionUpdateCount());

Session session = dvtsnfs2SessionFactory.getCurrentSession();

SessionStatistics sessionStats = session.getStatistics();

logger.info("Session Stats on 12.02.133.250: " + sessionStats.getCollectionCount());

} catch (Throwable exception) {

// TODO: handle exception. Log exception
logger.fatal("Initial SessionFactory creation to 12.02.133.250 failed." + exception);
throw new ExceptionInInitializerError(exception);

}*/

}

public static SessionFactory getSessionFactory() {

return sessionFactory;


}

/**
* @return Returns the dvtsnfs2SessionFactory.
*/
public static final SessionFactory getDvtsnfs2SessionFactory() {

return dvtsnfs2SessionFactory;

}

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

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.