-->
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.  [ 3 posts ] 
Author Message
 Post subject: Mapping of a list with jdk types
PostPosted: Fri Feb 20, 2009 10:25 am 
Newbie

Joined: Fri Feb 20, 2009 10:19 am
Posts: 1
Hi, I'm trying to map a list of Long objects in a class. For example,

public class Foo {
private List<Long> numbers;
}

I wrote the mapping in hbm as follows:

<list name="numbers" cascade="all">
<key column="id"/>
<index column="idx"/>
<one-to-many class="java.lang.Long"/>
</list>

When i run the code, i get the following exception saying that java.lang.Long is not mapped:

Invocation of init method failed; nested exception is org.hibernate.MappingException: Association references unmapped class: java.lang.Long
Caused by:
org.hibernate.MappingException: Association references unmapped class: java.lang.Long
at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2380)
at org.hibernate.cfg.HbmBinder.bindListSecondPass(HbmBinder.java:2231)
at org.hibernate.cfg.HbmBinder$ListSecondPass.secondPass(HbmBinder.java:2729)
...

Is there another way to do it?

Thank you!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2009 10:47 am 
Beginner
Beginner

Joined: Thu Feb 19, 2009 5:48 am
Posts: 37
Location: Glasgow, Scotland
Because Long is an object you need a mapping or a custom user type for it.

_________________
##############################
If I helped, rate my comment, I have plenty of stupid questions to ask that I need credit for ;)
##############################


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2009 11:45 am 
Regular
Regular

Joined: Mon Apr 19, 2004 6:54 pm
Posts: 79
You should use 'element'
Code:
<list name="numbers" cascade="all">
  <key column="id"/>
  <index column="idx"/>
  <element column="number" type="long"/>
</list>


Christophe


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.