-->
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.  [ 2 posts ] 
Author Message
 Post subject: Troubles mapping many-to-one - should be basic solution
PostPosted: Mon Jan 10, 2011 2:31 pm 
Newbie

Joined: Mon Jan 10, 2011 1:50 pm
Posts: 3
Hi,

I have an object A that defines an attribute that is a List<B>. The A class has an appropriate getter and setter for B.

e.g.
public List<B> getBList();
public void setBList(List<B> b);

In the database, A's backing table declares a foreign key column referencing the primary key of B's backing table. A many-to-one seems the most appropriate solution for me as I want a uni-directional association from A to B.

My mapping looks like:

<class>
...
...

<joined-subclass name="path.to.A"
table="object_a_backing_table"

<key column="object_a_pk_column"

<many-to-one name="bList"
column="object_b_pk_column"
cascade="none"
fetch="join"/>
</joined-subclass>

...
</class>

When I try to load hibernate in my app context I get the following error :

"org.hibernate.MappingException: An association from the table object_a_backing_table refers to an unmapped class: 'java.util.List'"

I also tried adding the class="java.util.List" attribute on the many-to-one declaration but that failed too.

How do I do a many-to-one mapping? Is a hibernate many-to-one even appropriate for what I am trying to do?

Thanks In Advance!


Top
 Profile  
 
 Post subject: Re: Troubles mapping many-to-one - should be basic solution
PostPosted: Tue Jan 11, 2011 4:26 pm 
Newbie

Joined: Mon Jan 10, 2011 1:50 pm
Posts: 3
Please disregard. I revisited my object graph and realized that one-to-many was what is needed here.


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