<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.mobileserver.Player" table="player">
<id name="playerID" column="playerid" type="long" length="12">
<generator class="increment"/>
</id>
<property name="name" column="name" type="string" length="30" not-null="true"/>
<property name="phoneNo" column="phoneno" type="string" length="12" not-null="true"/>
<property name="type" column="type" type="string" length="1" not-null="true"/>
<property name="joinDate" column="joindate" type="timestamp" length="19" not-null="true"/>
<property name="password" column="password" type="string" length="15" not-null="true"/>
<many-to-one name="operator" class="com.mobileserver.Operator" not-null="true">
<column name="operatorid" />
</many-to-one>
<set cascade="all-delete-orphan" inverse="true" lazy="true" name="candidateSet" table="candidate">
<key column="playerID"/>
<one-to-many class="com.mobileserver.Candidate"/>
</set>
</class>
</hibernate-mapping>
.23:53:31,170 INFO Environment:462 - Hibernate 2.1.4
23:53:31,200 INFO Environment:496 - loaded properties from resource hibernate.properties: {hibernate.connection.username=mmgame, hibernate.connection.password=, hibernate.cglib.use_reflection_optimizer=false, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.connection.url=jdbc:mysql://localhost:3306/mmgame, hibernate.connection.driver_class=org.gjt.mm.mysql.Driver}
23:53:31,240 INFO Configuration:872 - configuring from resource: /hibernate.cfg.xml
23:53:31,240 INFO Configuration:844 - Configuration resource: /hibernate.cfg.xml
23:53:32,432 INFO Configuration:328 - Mapping resource: Operator.hbm.xml
23:53:32,813 INFO Binder:229 - Mapping class: com.mobileserver.Operator -> operator
23:53:33,173 INFO Configuration:328 - Mapping resource: Candidate.hbm.xml
23:53:33,263 INFO Binder:229 - Mapping class: com.mobileserver.Candidate -> candidate
23:53:33,313 INFO Configuration:328 - Mapping resource: Player.hbm.xml
23:53:33,434 INFO Binder:229 - Mapping class: com.mobileserver.Player -> player
23:53:33,444 INFO Configuration:328 - Mapping resource: GamePlay.hbm.xml
23:53:33,544 INFO Binder:229 - Mapping class: com.mobileserver.GamePlay -> gameplay
23:53:33,574 INFO Configuration:328 - Mapping resource: Groups.hbm.xml
23:53:33,674 INFO Binder:229 - Mapping class: com.mobileserver.Groups -> groups
23:53:33,674 INFO Configuration:328 - Mapping resource: InitState.hbm.xml
23:53:33,774 INFO Binder:229 - Mapping class: com.mobileserver.InitState -> initstate
23:53:33,774 INFO Configuration:328 - Mapping resource: Level.hbm.xml
23:53:33,834 INFO Binder:229 - Mapping class: com.mobileserver.Level -> level
23:53:33,834 INFO Configuration:328 - Mapping resource: CandidateType.hbm.xml
23:53:33,934 INFO Binder:229 - Mapping class: com.mobileserver.CandidateType -> candidatetype
23:53:33,944 INFO Configuration:1030 - Configured SessionFactory: null
23:53:33,944 INFO Configuration:613 - processing one-to-many association mappings
23:53:33,944 INFO Binder:1168 - Mapping collection: com.mobileserver.Operator.playerSet -> player
23:53:33,944 INFO Binder:1168 - Mapping collection: com.mobileserver.Candidate.gamePlaySet -> gameplay
23:53:33,954 INFO Binder:1168 - Mapping collection: com.mobileserver.Player.candidateSet -> candidate
23:53:33,984 INFO Binder:1168 - Mapping collection: com.mobileserver.Groups.gamePlaySet -> gameplay
23:53:33,984 INFO Binder:1168 - Mapping collection: com.mobileserver.InitState.groupsSet -> groups
23:53:33,984 INFO Binder:1168 - Mapping collection: com.mobileserver.Level.groupsSet -> groups
23:53:33,984 INFO Binder:1168 - Mapping collection: com.mobileserver.Level.candidateSet -> candidate
23:53:33,984 INFO Binder:1168 - Mapping collection: com.mobileserver.Level.gamePlaySet -> gameplay
23:53:33,984 INFO Binder:1168 - Mapping collection: com.mobileserver.Level.initStateSet -> initstate
23:53:33,984 INFO Binder:1168 - Mapping collection: com.mobileserver.CandidateType.candidateSet -> candidate
23:53:33,994 INFO Configuration:622 - processing one-to-one association property references
23:53:33,994 INFO Configuration:647 - processing foreign key constraints
23:53:34,105 INFO Dialect:82 - Using dialect: net.sf.hibernate.dialect.MySQLDialect
23:53:34,115 INFO SettingsFactory:62 - Use outer join fetching: true
23:53:34,135 INFO DriverManagerConnectionProvider:42 - Using Hibernate built-in connection pool (not for production use!)
23:53:34,145 INFO DriverManagerConnectionProvider:43 - Hibernate connection pool size: 5
23:53:34,145 INFO DriverManagerConnectionProvider:77 - using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost:3306/mmgame
23:53:34,145 INFO DriverManagerConnectionProvider:78 - connection properties: {user=mmgame, password=}
23:53:34,165 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
23:53:34,265 INFO SettingsFactory:102 - Use scrollable result sets: true
23:53:34,265 INFO SettingsFactory:105 - Use JDBC3 getGeneratedKeys(): true
23:53:34,265 INFO SettingsFactory:108 - Optimize cache for minimal puts: false
23:53:34,265 INFO SettingsFactory:117 - Query language substitutions: {}
23:53:34,265 INFO SettingsFactory:128 - cache provider: net.sf.ehcache.hibernate.Provider
23:53:34,275 INFO Configuration:1093 - instantiating and configuring caches
23:53:34,705 INFO SessionFactoryImpl:119 - building session factory
23:53:36,077 INFO SessionFactoryObjectFactory:82 - no JNDI name configured
.testStartGame
E.testEndGame
E
Time: 8.042
There were 2 errors:
1) testStartGame(com.mobileserver.PlayerTest)net.sf.hibernate.HibernateException: Found two representations of same collection
at net.sf.hibernate.impl.SessionImpl.updateReachableCollection(SessionImpl.java:2866)
at net.sf.hibernate.impl.FlushVisitor.processCollection(FlushVisitor.java:32)
at net.sf.hibernate.impl.AbstractVisitor.processValue(AbstractVisitor.java:69)
at net.sf.hibernate.impl.AbstractVisitor.processValues(AbstractVisitor.java:36)
at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2588)
at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2454)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2256)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2235)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at com.mobileserver.PlayerTest.testStartGame(PlayerTest.java:162)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.mobileserver.PlayerTest.main(PlayerTest.java:147)
2) testEndGame(com.mobileserver.PlayerTest)net.sf.hibernate.HibernateException: Found two representations of same collection
at net.sf.hibernate.impl.SessionImpl.updateReachableCollection(SessionImpl.java:2866)
at net.sf.hibernate.impl.FlushVisitor.processCollection(FlushVisitor.java:32)
at net.sf.hibernate.impl.AbstractVisitor.processValue(AbstractVisitor.java:69)
at net.sf.hibernate.impl.AbstractVisitor.processValues(AbstractVisitor.java:36)
at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2588)
at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2454)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2256)
at net.sf.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1801)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1567)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1532)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at com.mobileserver.PlayerTest.testEndGame(PlayerTest.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.mobileserver.PlayerTest.main(PlayerTest.java:147)
FAILURES!!!
Tests run: 3, Failures: 0, Errors: 2
Dear All,
I use MySQL4.0 and Hibernate to development a Mobile Game Platform. However while I try to update my data by this method "session.update(candidate)", it throws a Exception "Found two representations of same collection".
There mapping relationship like the following.
Player ---- Candidate One to Many
Candidate --------- GamePlay One to Many
GamePlay --------- Group Many to One
Group ------------- Level Many to One
Level -------------- Candidate One to Many
I think the problem is caused by the cycle relationship.
Candidate --- GamePlay --- Group --- Level --- Candidate
I am appreciate if you can give me some suggestion.
Thank you!
|