Ich habe bei dem Foreign Key jetzt mal ein "unique=true" eingefügt. Jetzt klappt beim ersten Save alles, aber schon vor dem Updaten nichts. Es kommt folgende Fehlermeldung. Hab zwar gegoogelt, aber nichts gefunden. Hat jemand ne Idee?
771 [main] INFO org.hibernate.connection.C3P0ConnectionProvider - C3P0 using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost:3306/Test
771 [main] INFO org.hibernate.connection.C3P0ConnectionProvider - Connection properties: {user=root, password=****}
771 [main] INFO org.hibernate.connection.C3P0ConnectionProvider - autocommit mode: false
Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@c5495e [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@16c163f [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, idleConnectionTestPeriod -> 0, initialPoolSize -> 1, maxIdleTime -> 0, maxPoolSize -> 5, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 1, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@1976011 [ description -> null, driverClass -> null, factoryClassLocation -> null, jdbcUrl -> jdbc:mysql://localhost:3306/Test, properties -> {user=******, password=******} ] , preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ] , factoryClassLocation -> null, numHelperThreads -> 3, poolOwnerIdentityToken -> c5495e ]
1392 [main] INFO org.hibernate.cfg.SettingsFactory - RDBMS: MySQL, version: 4.1.15-nt
1392 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.11 ( $Date: 2005-09-21 18:20:03 +0000 (Wed, 21 Sep 2005) $, $Revision: 4287 $ )
Exception in thread "main" exceptions.InfrastructureException: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at src.HibernateUtil.commitTransaction(HibernateUtil.java:73)
at daos.TeilDAO.teilNachId(TeilDAO.java:18)
at business.Berechnung.berechneOptBestellmenge(Berechnung.java:200)
at business.Berechnung.berechneMaxBestand(Berechnung.java:402)
at business.Berechnung.berechneMaxBestandsreichweite(Berechnung.java:416)
at business.Berechnung.berechnungStarten(Berechnung.java:46)
at src.Hibernatetest.main(Hibernatetest.java:304)1412 [main] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQLDialect
1412 [main] INFO org.hibernate.transaction.TransactionFactoryFactory - Using default transaction strategy (direct JDBC transactions)
1412 [main] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
1412 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
1412 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
1412 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
1412 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
1412 [main] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
1412 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled
1412 [main] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: null
1412 [main] INFO org.hibernate.cfg.SettingsFactory - Maximum outer join fetch depth: 2
1412 [main] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
1412 [main] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
1412 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
1412 [main] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
1412 [main] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
1412 [main] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
1412 [main] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
1412 [main] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
1412 [main] INFO org.hibernate.cfg.SettingsFactory - Cache provider: org.hibernate.cache.EhCacheProvider
1422 [main] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
1422 [main] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
1422 [main] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
1422 [main] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
1422 [main] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
1452 [main] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
1462 [main] WARN net.sf.ehcache.config.Configurator - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/E:/Workspace/Bestandsmanagement/lib/ehcache-1.1.jar!/ehcache-failsafe.xml
2113 [main] INFO org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
2113 [main] INFO org.hibernate.impl.SessionFactoryImpl - Checking 0 named queries
2533 [main] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 1062, SQLState: 23000
2533 [main] ERROR org.hibernate.util.JDBCExceptionReporter - Duplicate entry '934809' for key 1
2543 [main] ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:74)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:181)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at src.HibernateUtil.commitTransaction(HibernateUtil.java:69)
at daos.TeilDAO.teilNachId(TeilDAO.java:18)
at business.Berechnung.berechneOptBestellmenge(Berechnung.java:200)
at business.Berechnung.berechneMaxBestand(Berechnung.java:402)
at business.Berechnung.berechneMaxBestandsreichweite(Berechnung.java:416)
at business.Berechnung.berechnungStarten(Berechnung.java:46)
at src.Hibernatetest.main(Hibernatetest.java:304)
Caused by: java.sql.BatchUpdateException: Duplicate entry '934809' for key 1
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:647)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1722)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)
... 14 more
Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:74)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:181)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at src.HibernateUtil.commitTransaction(HibernateUtil.java:69)
... 6 more
Caused by: java.sql.BatchUpdateException: Duplicate entry '934809' for key 1
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:647)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1722)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)
... 14 more
|