-->
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: Mapping for generic classes
PostPosted: Tue Jan 16, 2007 12:59 pm 
Newbie

Joined: Tue Jan 16, 2007 12:49 pm
Posts: 1
Hello

i'm new to hibernate so i need a little help. I already googled for about 4 hours.
Here's my problem

I want to map a generic list like

Code:
public class ClassWithList {
  private List<E> list;
}


So I have the following mapping file:
Code:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping default-lazy="false">
    <class name="ClassWithList" table="ClassList">
          <list name="list" >
               <key column="OBSERVABLELIST_ID"/>
               <list-index column="sortOrder"/>
               <one-to-many class="________"/>
          </list>
     </class>
</hibernate-mapping>


My Problem is that i don't know the class of the objects in the list (see the ______ in the mapping file.
Is there any way to tell hibernate that this is a generic list?
The same problem with classes:
What would the mapping file for the following class look like:
Code:
/**
     * Class that encapsulates the methods for an observer of this list.
     */
    public class ListObserver<E> {
       
       private List<E> myListToObserve;

       public void setList(List<E> newList) {
           myLisstToObserve = newList;
       }

       public List<E> getList() {
             return myLisstToObserve;
       }

    }


Thanks for your answers!!!


Top
 Profile  
 
 Post subject: Use an element rather than a one-to-many.
PostPosted: Tue Jan 16, 2007 3:34 pm 
Newbie

Joined: Tue Jan 16, 2007 3:02 pm
Posts: 2
Rather than a <one-to-many>, you want an <element>.


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.