mardi 17 septembre 2019

HIbernate onetoMany mapping on non unique column

I have three tables player, Match and media as below

Player
    player_id-->PK
    Media_id

Match
    match_id-->PK
    Media_id

Media
   Media_internal_id --> PK
   Media_id 
   Other_details

Media id is non unique column can have duplicated and it is the joining column now i want to load all media Object associated with player

Tried Below

Player{
    @OneToMany
    @Formula("SELECT * FROM MEDIA WHERE MEDIA_ID = MEDIA_ID")
        private List<Media> media= new ArrayList<Media>();
}

Error:

o.h.e.jdbc.spi.SqlExceptionHelper - Table 'tennis.PLAYER_media' doesn't exist

Any adivce how it can be mapped




Aucun commentaire:

Enregistrer un commentaire