Boa noite! Tô com um problemão, é o seguinte, estou fazendo um joguinho tipo quiz, para a persistência dos dados estou usando o Hibernate, Tenho 3 classes, Pergunta, Alternativa e Jogador, A classe pergunta tem um atributo List < Alternativa >, acontece que quando eu rodo no servidor, o hibernate só cria as tabelas “Pergunta”, “Jogador” e uma tabela associativa “pergunta_alternativa” com dois atributos respectivos aos ids das tabelas, ele não cria a tabela “Alternativa”, com certeza eu errei algo, mas não consigo identificar o erro, alguém pode me mostrar onde errei, pois passei o dia todo procurando e não encontrei. Obrigada
Classe Pergunta:
@Entity
public class Question {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
private String title;
@OneToMany(mappedBy="question", targetEntity=Alternative.class, fetch=FetchType.LAZY, cascade=CascadeType.ALL)
private List<Alternative> alternatives;
@Enumerated(EnumType.STRING)
private Theme theme;
@Enumerated(EnumType.STRING)
private Level level;
public Question(){}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public List<Alternative> getAlternatives() {
return alternatives;
}
public void setAlternatives(List<Alternative> alternatives) {
this.alternatives = alternatives;
}
public Theme getTheme() {
return theme;
}
public void setTheme(Theme theme) {
this.theme = theme;
}
public Level getLevel() {
return level;
}
public void setLevel(Level level) {
this.level = level;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
Classe Alternativa:
@Entity
public class Alternative {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
private String title;
private Boolean right;
@ManyToOne
@JoinColumn(name="alternative_question")
private Question question;
public Alternative(){}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Boolean getRight() {
return right;
}
public void setRight(Boolean right) {
this.right = right;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Question getQuestion() {
return question;
}
public void setQuestion(Question question) {
this.question = question;
}
}
Classe Jogador:
@Entity
public class Player {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
private String nickname;
private String login;
private String password;
private Long score;
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Long getScore() {
return score;
}
public void setScore(Long score) {
this.score = score;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}