java - JPA/Hibernate: mapping a one to many relation to hashmap using part of embedded id as key (without join table) -


i stuck on following problem:

i have entity embedded composite id. entity used 'many' in 1 many relationship. want refer relationship on 'one' side map, key 1 attribute of embedded id, , value entity (see code below clarification).

i have tried several combinations of elementcollection, joincolumn, mapkeycolumn , mapkeyjoincolumn annotations, both jpa , hibernate specific ones, cannot work. maybe not possible embedded id?

@entity public class item {      @column      private long id;      //which annotations use here?     private map<team, teamstatus> statusses; } 

and

@entity public class team {      @column      private long id;     } 

and

@entity public class teamstatus {        @embeddedid      private itemteampk itemteampk;      @column      private boolean statusflag; } 

and

@embeddable public class itemteampk {      @manytoone     private team team;      @manytoone     private item item; } 

edit: note using jpa 2.1

errors get:

using

@javax.persistence.onetomany @javax.persistence.mapkeyjoincolumn(name = "itemteampk.team") private map<team, teamstatus> teamstatusses; 

gives

org.h2.jdbc.jdbcsqlexception: table "item_teamstatus" not found 

same when using team_id, itemteampk.team_id or other value name. same error occurs when using:

@javax.persistence.onetomany @javax.persistence.mapkey(name = "itemteampk") private map<team, teamstatus> teamstatusses ; 


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -