-->
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.  [ 1 post ] 
Author Message
 Post subject: Sets and sets within sets not working
PostPosted: Fri Sep 16, 2005 4:47 am 
Newbie

Joined: Fri Sep 16, 2005 4:34 am
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
2.0
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class name="fs.service.userregistry.userregistryS_default.datatype.SearchObj" table="SEARCH_RESULTS">

<composite-id name="PrimKey" class="fs.service.userregistry.userregistryS_default.datatype.SearchObjPrimaryKey">
<key-property name="searchID" column="SEARCHID" type="string"/>
</composite-id>

<set name="users" table="SEARCH_RESULTS_USRES">
<key column="SEARCHID"/>
<many-to-many class="fs.service.userregistry.userregistryS_default.datatype.UserDetailsCache"/>
</set>

</class>

<class name="fs.service.userregistry.userregistryS_default.datatype.UserDetailsCache" table="USERS">

<composite-id name="PrimKey" class="fs.service.userregistry.userregistryS_default.datatype.UserDetailsCachePrimaryKey">
<key-property name="userid" column="USERID" type="string"/>
</composite-id>

<set name="content" table="KEY_VALUE">
<key column="USERID"/>
<many-to-many class="fs.service.userregistry.userregistryS_default.datatype.KeyValue">
<column name="USERID"/>
<column name="KEY"/>
<column name="VALUE"/>
</many-to-many>
</set>

</class>

<class name="fs.service.userregistry.userregistryS_default.datatype.KeyValue" table="KEY_VALUE">

<composite-id name="PrimKey" class="fs.service.userregistry.userregistryS_default.datatype.KeyValuePrimaryKey">
<key-property name="userid" column="USERID" type="string"/>
<key-property name="key" column="KEY" type="string"/>
<key-property name="value" column="VALUE" type="string"/>
</composite-id>

</class>

</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Hi,

Could some one help me fix my problem with multiple sets.

If I remove the column "userid" from below
<set name="content" table="KEY_VALUE">
<key column="USERID"/>
<many-to-many class="fs.service.userregistry.userregistryS_default.datatype.KeyValue">
<column name="USERID"/>
<column name="KEY"/>
<column name="VALUE"/>
</many-to-many>
</set>
as it is still complaining. I get an error again with the following message

Foreign key (KEY_VALUE [KEY,VALUE])) must have same number of columns as the referenced primary key (KEY_VALUE [USERID,KEY,VALUE])

Full stack trace of any exception that occurs:
net.sf.hibernate.MappingException: Repeated column in mapping for collection: fs.service.userregistry.userregistryS_default.datatype.UserDetailsCache.content column: USERID
at net.sf.hibernate.collection.AbstractCollectionPersister.checkColumnDuplication(AbstractCollectionPersister.java:654)
at net.sf.hibernate.collection.AbstractCollectionPersister.<init>(AbstractCollectionPersister.java:167)
at net.sf.hibernate.collection.BasicCollectionPersister.<init>(BasicCollectionPersister.java:35)
at net.sf.hibernate.persister.PersisterFactory.createCollectionPersister(PersisterFactory.java:55)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:148)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:805)
at common.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:49)
at fs.connector.persistence.connector.HibernatePersistenceConnector.persist(HibernatePersistenceConnector.java:211)
at fs.connector.persistence.PersistenceManager.persist(PersistenceManager.java:119)
at fs.service.userregistry.userregistryS_default.datatype.UserRegistryPersistenceDAO.addUsers(UserRegistryPersistenceDAO.java:40)
at fs.service.userregistry.userregistryS_default.UserRegistryBean.searchAllUsers(UserRegistryBean.java:216)
at fs.service.userregistry.userregistryS_default.unitTest.UserRegistryUnitTest.testSearchAllUsers(UserRegistryUnitTest.java:133)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Name and version of the database you are using:
Oracle9i Enterprise Edition Release 9.2.0.6.0
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


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

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.