In a bean that has a OneToMany link, with others, through a HashMap what annotations should be used?
@Entity
class Rodada{
public HashMap<Pergunta,Resposta> perguntas;
In a bean that has a OneToMany link, with others, through a HashMap what annotations should be used?
@Entity
class Rodada{
public HashMap<Pergunta,Resposta> perguntas;
This relationship would be best structured within a wrapper class for these two entities:
@Entity
public class Questao {
@Id
private int id;
@OneToOne
private Pergunta pergunta;
@OneToOne
private Resposta resposta;
// getter, setter, hashCode, equals
}
So in your round class:
@Entity
public class Rodada {
//Id omitido
@OneToMany
@JoinColumn(name = "rodada_id")
private Set<Questao> questoes;
// getter, setter, hashCode, equals
}
If you still want to keep it as it is, here is an example taken from SOen that may help you:
@ElementCollection
@CollectionTable(name="<name_of_join_table>")
@MapKeyColumn(name="<name_of_map_key_in_table>")
Map<String, Person> personMap;