Created
May 29, 2018 16:06
-
-
Save nosrednawall/acffa649b536037d7346be1ff109571c to your computer and use it in GitHub Desktop.
Exemplo de mapeamento @OneToMany e @manytoone bidirecional
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
@Table(name = "evento") | |
public class Evento { | |
// ... Outros campos ... | |
@ManyToOne | |
@JoinColumn(name = "categoria_id") | |
private Categoria categoria; | |
// ... Outros campos e métodos ... | |
public Categoria getCategoria() { | |
return categoria; | |
} | |
} | |
@Entity | |
@Table(name = "categoria") | |
public class Categoria { | |
// ... Outros campos ... | |
@OneToMany(mappedBy = "categoria") | |
private List<Evento> eventos; | |
// ... Outros campos e métodos ... | |
public List<Evento> getEventos() { | |
return eventos; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment