-->
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: Problems with one-to-many relationships
PostPosted: Sun Sep 07, 2003 9:15 am 
Newbie

Joined: Sun Sep 07, 2003 9:09 am
Posts: 4
Hi. I have some problems with one-to-many relationships:
When I use the xdoclet as below:
/**
* @hibernate.set
* lazy="true"
* @hibernate.collection-key
* column="team_id"
* @hibernate.collection-one-to-many class="test.Player"
*/
public Set getPlayers() {
return players;
}
It results in the following mapping file:
<set
role="players"
lazy="true"
readonly="false"
cascade="none"
sort="unsorted"
>

<key
column="team_id"
>
</key>

<one-to-many
class="test.Player"
/>

</set>

Which in its turn during runtime gives the following error:
net.sf.hibernate.PropertyNotFoundException: Could not find a getter for null in class com.infonatural.Team and a total failure to run the program.

However if i add a property name="players" to the set tag, it works during runtime, but gives the following ugly message at setup:
[ERROR] XMLHelper - -Error parsing XML: XML InputStream(37) <org.xml.sax.SAXParseException: Attribute "name" must be declared for element type "set".>org.xml.sax.SAXParseException: Attribute "name" must be declared for element type "set".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)

Anything I am doing wrong? Should I worry about the second message? Everything does work..


Top
 Profile  
 
 Post subject: Using Hibernate 2.03 by the way..
PostPosted: Sun Sep 07, 2003 9:21 am 
Newbie

Joined: Sun Sep 07, 2003 9:09 am
Posts: 4
Using Hibernate 2.03 by the way..


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 07, 2003 9:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Make sure you are generating the code with XDoclet with the version 2 tag.


Top
 Profile  
 
 Post subject: Thanks
PostPosted: Sun Sep 07, 2003 9:24 am 
Newbie

Joined: Sun Sep 07, 2003 9:09 am
Posts: 4
I will try that.. Quick Idea where I add that tag? Using xdoclet 1.2b3


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 07, 2003 9:30 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
The ANT task for XDoclet requres the version to be set to version 2 rather than no version as it will generate mappings for version 1.x of Hibernate, eg,

<hibernatedoclet
destdir="${generated.home}"
excludedtags="@version,@author,@todo"
force="${generated.forced}"
mergedir="${generated.home}"
verbose="false">

<hibernate version="2.0"/> <!-- HERE -->

<fileset dir="${src.home}">
<include name="**/hibernate/*.java"/>
</fileset>

<hibernate/>

</hibernatedoclet>


See above. Ill have to add it to the docs.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 07, 2003 9:38 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Opps had it in there twice. Should be:
<hibernatedoclet
destdir="${generated.home}"
excludedtags="@version,@author,@todo"
force="${generated.forced}"
mergedir="${generated.home}"
verbose="false">

<fileset dir="${src.home}">
<include name="**/hibernate/*.java"/>
</fileset>

<hibernate version="2.0"/>

</hibernatedoclet>

It was in the dicumentation though I have made it more obvious to the casual reader.


Top
 Profile  
 
 Post subject: It worked.
PostPosted: Sun Sep 07, 2003 10:02 am 
Newbie

Joined: Sun Sep 07, 2003 9:09 am
Posts: 4
Thanks! That worked like a charm.


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.