-->
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: need help with tricky insert in join table using @ManyToMany
PostPosted: Thu Jan 19, 2012 8:02 am 
Newbie

Joined: Thu Jan 19, 2012 7:15 am
Posts: 1
Hi, Gentlemen. I need Your help with the following:
I have 2 Entities, say JOB_DESCR and KEYWORD, with many-to-many relationship. We introduced an additional table, JOB_DESCR_JOIN_KEYWORD to handle the relationship. However there's one tricky peculiarity here: besides the 2 usual columns in the JOB_DESCR_JOIN_KEYWORD table(foreignKeys to JOB_DESCR and KEYWORD) we wanna one more column --> KEYWORD_TYPE (yes, sure it would be logical to have the KEYWORD_TYPE in KEYWORD table, but we already have one, and need one more column like KEYWORD_TYPE in the join column, and this's a client's decision). I use annotations to describe the mapping:
Code:
@Entity
JobDescription {
private List jobKeywordsOfType1;
private List jobKeywordsOfType2;

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "JOB_DESCR_JOIN_KEYWORD",
               joinColumns = { @JoinColumn(name = "JOB_DESCR_ID", referencedColumnName = "ID")},
               inverseJoinColumns = { @JoinColumn(name = "KEYWORD_ID", referencedColumnName = "ID") })
   public getJobKeywordsOfType1() {
      return jobKeywordsOfType1;
   }
}

So my question is:
is there a way to somehow insert into the JOB_DESCR_JOIN_KEYWORD.KEYWORD_TYPE the value we want to (it'll be different for jobKeywordsOfType1/jobKeywordsOfType2 accordingly) and HOW(which annotation(s) etc) ??? I had to look through a lot of reference documentation and still haven't found a way to accomplish that. Yes, without the additional column with the above configuration preceding the getter ALL works fine. Any help upon the above, gents, would be highly appreciated..


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.