-->
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.  [ 7 posts ] 
Author Message
 Post subject: Repeated column in mapping for collection
PostPosted: Wed Feb 09, 2005 4:22 am 
Newbie

Joined: Wed Feb 09, 2005 4:00 am
Posts: 1
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 2.1

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

<hibernate-mapping>

<class name="au.gov.wa.transport.sandpit.poc.hibernate.business.AddressBean" table="poc_address">
<id name="id" column="address_id" type="long" unsaved-value="null">
<generator class="sequence">
<param name="sequence">dpi_uid_seq</param>
</generator>
</id>

<version column="version" name="version" type="long"/>

<property name="street" column="street" type="string" length="15" not-null="false"/>
<property name="town" column="town" type="string" length="15" not-null="false"/>
<property name="state" column="state" type="string" length="15" not-null="false"/>
<property name="postcode" column="postcode" type="string" length="15" not-null="false"/>

<map name="people" table="poc_person_address" lazy="false" inverse="true">
<key column="address_id" />
<index type="long" column="person_id" />
<many-to-many class="au.gov.wa.transport.sandpit.poc.hibernate.business.PersonBean" column="person_id" />
</map>



</class>

</hibernate-mapping>

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

<class name="au.gov.wa.transport.sandpit.poc.hibernate.business.PersonBean" table="poc_person">
<id name="id" column="person_id" type="long" unsaved-value="null">
<generator class="sequence">
<param name="sequence">dpi_uid_seq</param>
</generator>
</id>

<version column="version" name="version" type="long"/>

<property name="firstname" column="firstname" type="string" length="15" not-null="false"/>
<property name="lastname" column="lastname" type="string" length="15" not-null="false"/>

<map name="addresses" table="poc_person_address" lazy="false" cascade="save-update">
<key column="person_id"/>
<index type="long" column="address_id"/>
<many-to-many class="au.gov.wa.transport.sandpit.poc.hibernate.business.AddressBean" column="address_id"/>
</map>

</class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

Problem in obtaining a SessionFactory

Full stack trace of any exception that occurs:
09 Feb 2005 14:55:18 - INFO - net.sf.hibernate.dialect.Dialect:83 - Using dialect: net.sf.hibernate.dialect.OracleDialect
09 Feb 2005 14:55:18 - INFO - net.sf.hibernate.util.NamingHelper:26 - JNDI InitialContext properties:{}
09 Feb 2005 14:55:18 - INFO - net.sf.hibernate.connection.DatasourceConnectionProvider:52 - Using datasource: test
09 Feb 2005 14:55:18 - INFO - net.sf.hibernate.impl.SessionFactoryImpl:162 - Use outer join fetching: true
09 Feb 2005 14:55:18 - INFO - net.sf.hibernate.impl.SessionFactoryImpl:185 - Use scrollable result sets: true
09 Feb 2005 14:55:18 - INFO - net.sf.hibernate.impl.SessionFactoryImpl:186 - JDBC 2 max batch size: 15
09 Feb 2005 14:55:19 - ERROR - au.gov.wa.transport.sandpit.poc.hibernate.util.HibernateUtil:25 - Initial SessionFactory creation failed
net.sf.hibernate.MappingException: Repeated column in mapping for collection: au.gov.wa.transport.sandpit.poc.hibernate.business.AddressBean.people column: person_id
at net.sf.hibernate.collection.CollectionPersister.checkColumnDuplication(CollectionPersister.java:838)
at net.sf.hibernate.collection.CollectionPersister.<init>(CollectionPersister.java:214)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:216)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:627)
at au.gov.wa.transport.sandpit.poc.hibernate.util.HibernateUtil.<clinit>(HibernateUtil.java:23)
at au.gov.wa.transport.sandpit.poc.hibernate.transaction.Transaction.getSession(Transaction.java:77)
at au.gov.wa.transport.sandpit.poc.hibernate.transaction.AddPersonTransaction.execute(AddPersonTransaction.java:30)
at au.gov.wa.transport.sandpit.poc.hibernate.business.ServiceProviderBD.savePerson(ServiceProviderBD.java:95)
at au.gov.wa.transport.sandpit.poc.hibernate.action.PersonAction.perform(PersonAction.java:55)
at org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.java:1787)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1586)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:996)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6452)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3661)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2630)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)

Name and version of the database you are using:
Oracle 8.1.7
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject: same problem; did you find any solution ?
PostPosted: Mon Feb 21, 2005 11:21 am 
Beginner
Beginner

Joined: Thu Jun 17, 2004 10:08 am
Posts: 21
Location: Paris-France
Hi i have the same problem tthat you; did you find any solution?
Thank's

Ady


Top
 Profile  
 
 Post subject: same problem; did you find any solution ?
PostPosted: Mon Feb 21, 2005 11:21 am 
Beginner
Beginner

Joined: Thu Jun 17, 2004 10:08 am
Posts: 21
Location: Paris-France
Hi i have the same problem tthat you; did you find any solution?
Thank's

Ady


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 21, 2005 6:01 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
use HB3


Top
 Profile  
 
 Post subject: achieving this in HB3
PostPosted: Mon Mar 07, 2005 7:50 pm 
Newbie

Joined: Mon Mar 07, 2005 7:46 pm
Posts: 2
Hi,

I am in the same situation as the people above. However, I am using HB3 (rc1) and still cannot get this type of mapping to work.

I've searched the docs but cannot find an example of mapping a many-to-many with the map-key column being the same as the as the many-to-many column.

Can anyone point me to a correct mapping for this?

Thanks,

Robin


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 07, 2005 7:53 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
<map-key formula="..."/>


there are serveral examples of this in the HB3 test suite


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 07, 2005 8:07 pm 
Newbie

Joined: Mon Mar 07, 2005 7:46 pm
Posts: 2
Gavin, thanks for such a quick response - I will take a look there and I am sure all will become clear.

Robin


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