-->
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: How to map two collections onto one table?
PostPosted: Mon Aug 02, 2004 1:19 pm 
Beginner
Beginner

Joined: Mon Aug 02, 2004 1:08 pm
Posts: 42
Hi.

In my classI have two lists with elements of the same type.
Code:
    /**
     * Objects of the following type(s) are allowed in the list
     * {@link my.MultilingualType}
     */
    java.util.List getDescription();

    /**
     * Objects of the following type(s) are allowed in the list
     * {@link my.MultilingualType}
     */
    java.util.List getName();


I would entries of these lists to be stored in one table. What is the preferred way to do it?

I've tried the following mapping:
Code:
    /**
     *
     * @hibernate.list cascade="all"
     * @hibernate.collection-key column="ServicePImpl_id"
     * @hibernate.collection-index column="index"
     * @hibernate.collection-one-to-many class="my.impl.MultilingualTypeImpl"
     *
     */
    public java.util.List getDescriptionInternal() {
        return _DescriptionInternal;
    }

    /**
     *
     * @hibernate.list cascade="all"
     * @hibernate.collection-key column="ServicePImpl_id"
     * @hibernate.collection-index column="index"
     * @hibernate.collection-one-to-many class="my.impl.MultilingualTypeImpl"
     *
     */
    public java.util.List getNameInternal() {
        return _NameInternal;
    }


This failed, since first elements of both lists have the same index (it's 0). After loading, I have the same element as the first element of both lists.

Code:
INSERT INTO MULTILINGUALTYPEIMPL VALUES('id1','Cool','eng','id0',0)
INSERT INTO MULTILINGUALTYPEIMPL VALUES('id2','MyName','eng','id0',0)


I have two ideas:
1) Use different index columns and a filtering sql expression in where attribute of the list mapping.
2) Use many-to-many mappings with a separate intermediate tables for each of the collections.

However, I'm a bit lost with this (seemingly) simple mapping task.

I would be gratefult for any help/comments/ideas.

Thank you for your time.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 04, 2004 4:36 am 
Beginner
Beginner

Joined: Mon Aug 02, 2004 1:08 pm
Posts: 42
Any opinions anyone? Please...


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.