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.  [ 4 posts ] 
Author Message
 Post subject: how do i generate a list using hibernate? (currently stuck)
PostPosted: Mon Mar 06, 2006 9:17 am 
Newbie

Joined: Mon Mar 06, 2006 8:59 am
Posts: 2
Hibernate version: 3.1.2

First post here, so please tell me if i'm not tuned in to the forum's culture..
(and english isn't my first language, so glaring grammatical errors are possible)

my problem is: i'm trying to generate a class with a "List" element, but keep
getting error messages from the IDE i use (jboss 1.5, eclipse 3.1.1):

code:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 12:56:49 19/02/2006 by Hibernate Tools 3.1.0.beta4 -->
<hibernate-mapping>
    <class name="HiberGenesis.hib.ConnectionHib" table="connection" >
        <id name="id" type="integer">
            <column name="ID" />
            <generator class="native" />
        </id>
       

        <many-to-one name="itemFrom" class="HiberGenesis.hib.ItemHib" fetch="select">
            <column name="ITEM_FROM" not-null="true" />
        </many-to-one>
       
        <list name="connectionPropertyList" inverse="true">
               <key column="CONNECTION_ID" not-null="true"/>        

              <one-to-many class="HiberGenesis.hib.ConnectionPropertyHib" />
        </list>
       
    </class>
</hibernate-mapping>



i've created this code using a reference from the internet:
http://www.nabble.com/Re:-Weird-1-to-n- ... c2369.html

i've also tried the following variation:

Code:
<list name="connectionProperties" inverse="true">
  <key>
            <column name="BC_CONNECTION_ID" not-null="true" />
  </key>
            <one-to-many class="HiberGenesis.hib.hib.ConnectionPropertyHib" />
</list>


the error message i'm getting:

Quote:
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*)".


i've tried to find a solution to this problem on the internet, as well as
fiddling with the xml for a while, but couldn't find a solution (it seems that it should work, but it doesn't )


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 06, 2006 12:48 pm 
Regular
Regular

Joined: Tue Jan 03, 2006 9:52 am
Posts: 52
Location: Zurich
Hello,
If you use list, you need an list-index attribute.

Code:
<list name="connectionPropertyList" inverse="true">
   <key column="CONNECTION_ID" not-null="true"/>       
   <list-index column="position">
   <one-to-many class="HiberGenesis.hib.ConnectionPropertyHib" />
</list>


If you do not need an index, you could use a bag instead (or set).

Hope this helps!

Urs


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 06, 2006 12:50 pm 
Newbie

Joined: Mon Mar 06, 2006 8:59 am
Posts: 2
thanks a bunch! that solved the problem!

woohoo!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 06, 2006 12:54 pm 
Regular
Regular

Joined: Tue Jan 03, 2006 9:52 am
Posts: 52
Location: Zurich
Quote:
First post here, so please tell me if i'm not tuned in to the forum's culture..
(and english isn't my first language, so glaring grammatical errors are possible)

If someone could help you, you are able to rate his answer ;-)


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