-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate fügt endlos ein --> Mapping Problem
PostPosted: Mon Nov 14, 2005 2:04 pm 
Newbie

Joined: Thu Oct 20, 2005 5:25 am
Posts: 14
Guten Abend!

Ich habe ein Problem:

Ich habe ein Entity "Teil", bei dem eines der Properties ein Hashset "Reichweite" mit 5 (bzw. mit foreign key 6) Werten ist. Wenn ich jetzt die Reichweite berechne und einfüge, hängt sich Hibernate in eine Schleife von tausenden inserts. Mein Rechner dreht dabei, wenn ich es nicht schnell abbreche, im Roten. Ich habe allerdings keine Idee, woran das liegen kann.
Wenn ich die Beziehung als "inverse = true" modelliere tritt das Problem zwar nicht mehr auf, aber ich kann garnichts mehr updaten...

Das Mapping habe ich mal angehängt. Ich hoffe, ihr könnt mir weiterhelfen.

Danke,
bande


Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="model">
  <class name="Teil" table="teil" optimistic-lock="none">
    <id name="teilId" type="long" unsaved-value="null" column="teil_id">
      <generator class="native"/>
    </id>
    <!-- teilNr und teilBezeichnung duerfen nicht 'null' sein, weil braucht presentation-tier zur Anzeige-->
    <property name="teilBezeichnung" type="string" column="teil_bezeichnung" not-null="true"/>
    <!-- mengeneinheit darf 'null' sein, falls nicht gepflegt wird -->
    <property name="mengeneinheit" type="string" column="mengeneinheit"/>

...

    <set name="reichweite" table="teil_reichweite" cascade="all" lazy="false">
      <key foreign-key="reichweite_teilId" column="reichweite_teil_id"/>
      <composite-element class="model.Reichweite">
        <property name="bestandsreichweite" type="integer" column="bestandsreichweite"/>
        <property name="normRwIst" type="double" column="norm_rw_ist"/>
        <property name="normRwMax" type="double" column="norm_rw_max"/>
        <property name="normRwMin" type="double" column="norm_rw_min"/>
        <property name="normRwSoll" type="double" column="norm_rw_soll"/>
        <property name="ampelstatus" type="string" column="ampelstatus"/>
      </composite-element>
    </set>
   

...

  </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 2:27 pm 
Newbie

Joined: Thu Oct 20, 2005 5:25 am
Posts: 14
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.