2015년 12월 25일 금요일

Entity Inheritance [Abstract Entities]

abstract class는 @Entity 어노테이션을 선언함으로 인해서, entity로 선언되어질 수 있다.
abstract class는 구체화된 클래스와 거의 같지만 객체화할 수는 없다.

Abstract entity는 구체화된 entity처럼 쿼리할 수 있다. 만약 abstract entity가 query의
목표라면, query는 abstract entity의 하위 모든 구체화된 클래스에 동작한다.

@Entity
public abstract class Employee {
    @Id
    protected Integer employeeId;
    ...
}
@Entity
public class FullTimeEmployee extends Employee {
    protected Integer salary;
    ...
}
@Entity
public class PartTimeEmployee extends Employee {
    protected Float hourlyWage;
}

original source : https://docs.oracle.com/javaee/6/tutorial/doc/bnbqn.html

댓글 없음 :

댓글 쓰기