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