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: