-->
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: Mapping join table with a map
PostPosted: Thu Nov 29, 2007 1:26 pm 
Newbie

Joined: Thu Nov 29, 2007 12:57 pm
Posts: 1
Hi guys

I'd like to know if i con do this and how can i do it with @MapKeyManyToMany


i have this database schema structure

first these two tables

IDIOMA
IDIO_SQ_ID number(10) PK
IDIO_NOME varchar2(30)
...... another meaningless columns

UN_ORGANIZACIONAL
UNOR_SQ_ID number(10) PK
...... another meaningless columns


and a joinTable

UN_ORGANIZACIONAL_IDIOMA
UNOR_SQ_ID number(10) FK(UN_ORGANIZACIONAL.PK)
IDIO_SQ_ID number(10) FK(IDIOMA.PK)
UNOR_IDIO_NOME varchar2(50)



i mapped my classes in this way

Code:
@Entity
@Table(name= "IDIOMA")
public class Idioma  extends FwjBaseEntidade {

@Id
@Column(name= "IDIO_SQ_ID")
private Long codigoIdioma;
   
@Column(name = "IDIO_NOME")
private String nomeIdioma;


//............ rest of body of the class


and my problem below


Code:
@Entity
@Table(name="UN_ORGANIZACIONAL")
public class TipoUnidadeOrganizacional extends FwjBaseEntidade {

@Id
@Column(name="UNOR_SQ_ID")
private Long id;


//------------- Important part ---------------------------------
Code:
@ManyToMany
@JoinTable(name="UN_ORGANIZACIONAL_IDIOMA"
      ,joinColumns=@JoinColumn(columnDefinition="UNOR_SQ_ID")
      ,inverseJoinColumns=@JoinColumn(columnDefinition="UNOR_SQ_ID")
      ,uniqueConstraints=@UniqueConstraint(columnNames={"UNOR_SQ_ID", "IDIO_SQ_ID"})
   )

@MapKeyManyToMany(joinColumns=@JoinColumn(columnDefinition="IDIO_SQ_ID"),targetEntity=Idioma.class)

private Map<Idioma,String> nomes;

//...... rest of the body
-------------------------------------------------------------------



that string that is the value of the map i'd like represents the
UN_ORGANIZACIONAL_IDIOMA.UNOR_IDIO_NOME

but how i map it

i 'haven't mapped the UN_ORGANIZACIONAL_IDIOMA table in anywhere else i'm trying to do this without a association class

can i do what i'm intending to(do this map without create a new class)?

Or there's noway to do whatta want using this way ?


thank you all
and answer my questions
thx again


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.