2010-08-18 3 views
15

나는 모든 필드가 정확히 (정확히) 3 개의 차이가있는 4 개의 영속 클래스를 가진다. 1) 클래스 이름, 2) 테이블 이름, 3) 데이터이다. 나는 이것이 어떤 사람들에게 이상하게 보일지 모른다는 것을 알고 있지만, 여기에 들어 가지 않을 충분한 이유가 있음을 믿어 라. ..javax.persistence 어노테이션 및 상속

@Entity 
@Table(name = "store") 
public class Store 
{ 
@Id 
@Column(name = "unique_id") 
protected String id; 
@Column 
protected String category; 
... 
} 

을이 하나의 독립 실행 형 클래스, 그러나 많은 분야가 작업을 수행

지금, 난과 같이 작동합니다 내 클래스를 구성하는 주석을 최대 절전 모드 사용하고 있습니다 즉,지도 및 난 네 유사한 클래스 1 안타에 모든 것을 할 싶습니다 그러나

public class StoreBase 
{ 
@Id 
@Column(name = "unique_id") 
protected String id; 
@Column 
protected String category; 
... 
} 

@Entity 
@Table(name = "store1") 
public class Store1 extends StoreBase 
{} 

@Entity 
@Table(name = "store2") 
public class Store2 extends StoreBase 
{} 

@Entity 
@Table(name = "store3") 
public class Store3 extends StoreBase 
{} 

@Entity 
@Table(name = "store4") 
public class Store4 extends StoreBase 
{} 

이것을 시도 할 때 다음과 같은 예외가 얻을 :

Caused by: org.hibernate.AnnotationException: No identifier specified for entity: package.entities.Store1 
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:672) 
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:546) 
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:291) 
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292) 
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867) 

수퍼 클래스가 식별자를 검색하지 않았기 때문에 이것이라고 생각하십니까?

이 컨텍스트에서 상속을 활용하는 방법은 무엇입니까?

감사합니다.

+1

변경된 태그 이것은 최대 절전 모드 주석이 아니라 최대 절전 모드를 사용하는 jpa에 관한 것입니다. –

답변

27
@MappedSuperclass 
public class StoreBase 

자세한 내용은 docs을 참조하십시오.