-->
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.  [ 1 post ] 
Author Message
 Post subject: Help with complex mapping
PostPosted: Wed Feb 03, 2010 9:30 am 
Newbie

Joined: Wed Feb 03, 2010 9:17 am
Posts: 5
Hello there! We have the following schema:

MEDIA{
ID}

METADATA{
ID
DESCRIPTION}

MEDIA_METADATA{
ID_MEDIA
ID_METADATA
}

METADATA_VALUE{
ID_MEDIA
ID_METADATA
VALUE
}

The whole idea here is that a Media has a collection of metadata elements. Each metadata has a collection of values. So let's say I have a metadata named "TAG" I would have just one entry on METADATA:

ID:1
VALUE:TAG

And a Media has many tags: soccer, world cup, etc...

ID_MEDIA:1
ID_METADATA:1
VALUE:soccer

ID_MEDIA:1
ID_METADATA:1
VALUE:world cup

and I would like to map this as:L
Code:
public Class Media{

@OneToMany
    @JoinTable(name="MEDIA_METADATA", joinColumns=@JoinColumn(name="METADATA_ID"),inverseJoinColumns=@JoinColumn(name="MEDIA_ID"))
    protected Set<Metadata> metadata;
   
...

}

public class Metadata extends BaseEntity {

  @CollectionOfElements(targetElement=java.lang.String.class)
    @JoinTable(name="METADATA_MEDIA_VALUE", joinColumns={@JoinColumn(name="MEDIA_ID"),@JoinColumn(name="METADATA_ID")})
    @Column(name="VALUE_ATTR")
    private List<String> values;
...



This is my problem, the Metadata table has only one key METADATA_ID but since the relationship is resolved using a Ternary table, I was hopping I could use the key from that table to propagate the value.

Is it possible to map this relationship? Using those tables?

Regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.