Skip to content

Instantly share code, notes, and snippets.

@kaissi
Created September 25, 2020 20:38
Show Gist options
  • Save kaissi/abc89b389dc369a01c32745267f88963 to your computer and use it in GitHub Desktop.
Save kaissi/abc89b389dc369a01c32745267f88963 to your computer and use it in GitHub Desktop.
Mapeamento com @MappedSuperclass
@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