[Item]
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn
public class Item {
@Id @GeneratedValue
private Long id;
private String name;
private int price;
}
[Album]
@Entity
@DiscriminatorValue("ALBUM")
public class Album extends Item {
private String artist;
}
[Movie]
@Entity
@DiscriminatorValue("MOVIE");
public class Movie extends Item {
private String director;
private String actor;
}
[JpaMain]
Movie movie = new Movie();
movie.setDirector("aaaaa");
movie.setActor("bbbb");
movie.setName("바람과 함께 사라지다");
movie.setPrice(10000);
em.persist(movie);