-->
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: Native array mapping
PostPosted: Mon May 17, 2004 4:17 pm 
Newbie

Joined: Mon May 17, 2004 4:05 pm
Posts: 3
So i have class with String[] , and as reference says i am mapping it as:

<primitive-array name="names">
<element type="string"/>
</primitive-array>

I dont see any issues with dtd in it, and then i am getting:

Caused by: java.lang.ClassCastException
at net.sf.hibernate.cfg.Binder.bindArray(Binder.java:689)
at net.sf.hibernate.cfg.Binder$7.create(Binder.java:1388)
at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:952)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:338)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1167)

When i am trying to add mapping to hibernate.

I tried to specify String/java.lang.String/string as name type and each one fails.
Whats the secret?

Thanks..


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 4:19 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
A String is not a primitive.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 4:34 pm 
Newbie

Joined: Mon May 17, 2004 4:05 pm
Posts: 3
well problem is - java.lang.String throws exact same exception.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 4:36 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
So, java.lang.String is also not a primitive in Java.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 4:50 pm 
Newbie

Joined: Mon May 17, 2004 4:05 pm
Posts: 3
Well, yes and no.

this is bit from documentation:
<set name="names" table="NAMES">
<key column="GROUPID"/>
<element column="NAME" type="string"/>
</set>
(which is apparently not working. As well as "integer" and "date")


I also have absolutely no issues with using :
<property name="email" type="java.lang.String"/>

therefore there seems to be some inconsistency in way of implementation of Hibernate, isnt it?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 4:52 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
I'm sorry, but all that doesn't make java.lang.String a primitive! You can't use a <primitive-array> mapping with a non-primitive type, use <array>.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 4:53 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
And read some beginner Java documentation to find out about the difference between primitive and non-primitive types. Then, continue with the Hibernate documentation to understand Hibernate mapping types.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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.