2
In a bean that has a Onetomany connection, with others, through a Hashmap that annotations should be used?.
@Entity
class Rodada{
public HashMap<Pergunta,Resposta> perguntas;
2
In a bean that has a Onetomany connection, with others, through a Hashmap that annotations should be used?.
@Entity
class Rodada{
public HashMap<Pergunta,Resposta> perguntas;
2
This relationship would be better 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 class of rounds:
@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 the way it is, follow an example taken from Soen that can help you:
@ElementCollection
@CollectionTable(name="<name_of_join_table>")
@MapKeyColumn(name="<name_of_map_key_in_table>")
Map<String, Person> personMap;
Browser other questions tagged java hibernate jpa-2.0
You are not signed in. Login or sign up in order to post.