OneToMany Relationship to Class with Composite PrimaryKey in Hibernate

1

I have the following relationship

IntheScaleDefinitionentity,IhaveacompositeprimarykeyfaultconsistingofidEscaleDetailsandidTurma

IamhavingdoubtstodothereversemappingbetweenScaleDetailsandScaleDefinitionusinghibernatesinceIhavean@Embeddableclassasaprimarykey,asbelow:

@EmbeddablepublicclassEscalaDiaDetalhePKimplementsSerializable{@ManyToOne(fetch=FetchType.LAZY)@JoinColumn(name="mycolmumn")
    protected EscalaDetalhe escalaDia;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "idTurma")
    protected Turma turma;

     //getters , setters , hash and equals
}

I have the class DefinitionScan:

@Entity
@Table(name = "")
public class DefinicaoEscala {

    @EmbeddedId
    private EscalaDiaDetalhePKBean id;
    @ManyToOne  
    private Turno turno;
}

And I want to do the reverse OneToMany for the definition entity, I've tried it as described below:

@Entity
@Table(name ="ESCALADETALHE")
public class EscalaDetalhe{

   //properties
  @OneToMany(fetch = FetchType.EAGER , mappedBy = "",orphanRemoval = true,cascade = CascadeType.ALL )
    public List<DefinicaoEscala> definicoes;


}
  

What should I put in the mappedBy ?

    
asked by anonymous 17.08.2018 / 15:10

0 answers