-->
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: mapping of a list with a many to many
PostPosted: Thu Oct 13, 2005 9:16 am 
Beginner
Beginner

Joined: Sun Dec 05, 2004 10:25 am
Posts: 23
Hibernate 3.0
DB Postgres

I am trying to get a list which is an attribute of my class Server. It is a list of class Service. The db tables here are a many to many. So I have table server, service, and serverservice. table serverservice has 3 columns the primary key and teh 2 foriegn keys. Here is the error I am getting and the mapping file. I know I am leaving something out of teh mapping file but I am not sure what.

here is my list in the mapping
Code:
        <list name="services" table="serverservice" cascade="save-update" lazy="true">
        <key>
        <column name="fkserver" not-null="false"/>
        </key>
         <many-to-many class="edu.bju.aem.util.model.Service" column="fkservice" />
        </list>


Caused by: org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:399)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:449)
... 16 more
Caused by: org.xml.sax.SAXParseException: The content of element type "list" must match "(meta*,subselect?,cache?,synchronize*,comment?,key,(index|list-index),(element|one-to-many|many-to-many|composite-element|many-to-any),loader?,sql-insert?,sql-update?,sql-delete?,sql-delete-all?,filter*)".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)[/code]


Top
 Profile  
 
 Post subject: <index> is missed
PostPosted: Fri Oct 14, 2005 5:07 am 
Newbie

Joined: Wed Sep 17, 2003 3:31 am
Posts: 10
Location: Napoli (IT)
You have to specify the <index> element, that is the column in witch the index list will be stored.

Code:
<list name="services" table="serverservice" cascade="save-update"  lazy="true">
        <key>
        <column name="fkserver" not-null="false"/>
        </key>

<index column="idx" />

         <many-to-many class="edu.bju.aem.util.model.Service" column="fkservice" />
        </list>




'idx' will be a numeric column in table 'serverservice'.


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.