Created
September 25, 2020 20:38
-
-
Save kaissi/abc89b389dc369a01c32745267f88963 to your computer and use it in GitHub Desktop.
Mapeamento com @MappedSuperclass
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
@MappedSuperclass | |
public abstract class Biscoito { | |
@Id | |
@Column | |
protected Long id; | |
} | |
@Entity | |
public class BiscoitoChocolate extends Biscoito { | |
@OneToMany(cascade = CascadeType.ALL, mappedBy = "biscoito") | |
private Set<Sobremesa> sobremesas; | |
} | |
@Entity | |
public class BiscoitoBaunilha extends Biscoito { | |
@OneToMany(cascade = CascadeType.ALL, mappedBy = "biscoito") | |
private Set<Sobremesa> sobremesas; | |
} | |
@Entity | |
public class Sobremesa { | |
@ManyToOne | |
@JoinColumn(name = "biscoito_fk", nullable = false) | |
private Biscoito biscoito; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment