-->
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.  [ 6 posts ] 
Author Message
 Post subject: <index> requires a numeric column
PostPosted: Thu Jul 22, 2004 6:24 pm 
Newbie

Joined: Tue Jul 20, 2004 6:08 am
Posts: 4
Hi,

It seem that the <index> tag of a collection requires a numeric field. It accepts the "type" attribute but seems to ignore it.

This is valid according to the DTD:
Code:
    <list name="RelArticle">
      <key column="AuthorID"/>
      <index column="Name" type="string"/>
      <one-to-many class="Article"/>
    </list>


But it casts the the followinf exception:
Code:
Caused by: java.sql.SQLException: Invalid value for getInt() - 'Almennt um eplica' at com.mysql.jdbc.ResultSet.getInt(ResultSet.java:1276)


Am I doing something wrong here or is this a known issue.

Regards,
-Stefan


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 22, 2004 6:26 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Sorry, but what else should the index type of a List be? Maybe you are looking for <map>?

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


Top
 Profile  
 
 Post subject: I guess...
PostPosted: Thu Jul 22, 2004 6:37 pm 
Newbie

Joined: Tue Jul 20, 2004 6:08 am
Posts: 4
I guess you are right but it's by no means obvious (at least not to me). I thought I would get a ordered list back and since I'm implimenting that interface in my POJO beans I thought I could use that directly.

Thank you for your prompt response. I wil impliment the the correct way.

Best regards,
-Stefan


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 22, 2004 6:41 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Hum, it should be obvious that a Java List has a numeric index. If you use <list>, this is what you get. If you use <bag> (see the documentation for what a Bag is), you can use sort and order attributes and let the database sort your collection.

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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 22, 2004 6:58 pm 
Newbie

Joined: Tue Jul 20, 2004 6:08 am
Posts: 4
It looked to me that the index column is used for sorting when calling the database for the items that should be included in the list.

Are you impliying that a Lists can not be baes on sorted query results or that the value of a index field for the returned List is also used as the index of a particular entry in the List?

I may not be a seasoned Java programmer but retrieving such a List did not seem like such a bad idea.

Anyway, I'm on the right track now.

Thank you,
-Stefan


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 22, 2004 8:21 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Think ArrayList where the index is the position of the item in the Array. If there are gaps in the index sequence then a null will be the resulting object at that position.


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