-->
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.  [ 12 posts ] 
Author Message
 Post subject: simple one to many string mapping using xdoclet
PostPosted: Thu Jan 15, 2004 11:36 am 
Beginner
Beginner

Joined: Thu Jan 15, 2004 11:16 am
Posts: 37
I have a class A which contains a messages field. This is a Set of Strings.
So on the getMessages() method I have the following javadoc...

* @hibernate.set role="messages"
* @hibernate.collection-key column="foreignkeyid"
* @hibernate.collection-element column="message" type="string"

When I attempt to load my mappings I get the following error...

[junit] (cfg.Configuration 289 ) Could not configure datastore from input stream
[junit] java.lang.NullPointerException
[junit] at net.sf.hibernate.util.StringHelper.qualify(StringHelper.java:241)
[junit] at net.sf.hibernate.cfg.Binder.bindCollection(Binder.java:472)
[junit] at net.sf.hibernate.cfg.Binder$2.create(Binder.java:1382)
[junit] at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:989)
[junit] at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:344)
[junit] at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1204)
[junit] at net.sf.hibernate.cfg.Configuration.add(Configuration.java:247)
[junit] at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:28
1)

I guess that Im unsure how to configure a simple String onetomany using xdoclet.

Ta,
Stuart.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2004 12:09 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
How does the generated mapping look like? Does it work without the set?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2004 12:31 pm 
Beginner
Beginner

Joined: Thu Jan 15, 2004 11:16 am
Posts: 37
Yes it does work without the set
The mapping file looks like...

<set
role="messages"
lazy="false"
readonly="false"
cascade="none"
sort="unsorted"
>

<key
column="aid"
/>

<element
column="message"
type="string"
not-null="false"
unique="false"
/>

</set>

Im not a big hibernate expert so I cant usually spot dodgy mapping files.
Thanks for the help.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2004 12:32 pm 
Beginner
Beginner

Joined: Thu Jan 15, 2004 11:16 am
Posts: 37
Does hibernate know to automatically create a collection table for my Set of Strings when it sees a set mapping?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2004 12:34 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
There is no "role" attribute anymore in the <set> element, at least not in recent versions of Hibernate. It is now called "name" ... try leaving the role setting out of @hibernate.set


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2004 1:03 pm 
Beginner
Beginner

Joined: Thu Jan 15, 2004 11:16 am
Posts: 37
The xdoclet is now...

/** The getter method for this events messages
*
* @hibernate.set
* @hibernate.collection-key column="electioneventid"
* @hibernate.collection-element column="message" type="string"
*/


But still the same error.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2004 1:05 pm 
Beginner
Beginner

Joined: Thu Jan 15, 2004 11:16 am
Posts: 37
And the mapping file is...

<set
role="messages"
lazy="false"
readonly="false"
cascade="none"
sort="unsorted"
>

<key
column="electioneventid"
/>

<element
column="message"
type="string"
not-null="false"
unique="false"
/>

</set>


I can still see the role.
Do I need to change this to name?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2004 3:34 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Are you using an up to date xdoclet version?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 4:41 am 
Beginner
Beginner

Joined: Thu Jan 15, 2004 11:16 am
Posts: 37
That could be the issue.
Im currently using xdoclet-hibernate-module-1.2.jar

Ill see if there is a later one.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 4:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
I am using xdoclet-hibernate-module-1.2b4 here and it generates "name" attributes. Have you set <hibernate version="2.0"/> in your hibernatedoclet ant task?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 5:11 am 
Beginner
Beginner

Joined: Thu Jan 15, 2004 11:16 am
Posts: 37
I did not have...

version="2.0"

In my ant task. :-(
Im now onto a finding database dificulty and that is good because I have not started the database yet.
Big apologies for taking your time and thanks for all the help.

Ta,
Stuart.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 5:57 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
No problem :)


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