2011-08-19 6 views
0

나는 추상 클래스 A와 2 개의 클래스 B와 C를 구현하고있다.추상 클래스에서 선언 된 Hibernate 맵은 서브 클래스에서 상속받지 않는다.

abstract class A implements Serializable { 
    Long id 
    String code 
    String description 
    Map<Locale, String> localizedDescriptions 
} 

class B implements A {} 

class C implements A {} 
다음 하이버 네이트 매핑으로 :

<class name="A" abstract="true"> 

    <id name="id"> 
     <generator class="org.hibernate.id.enhanced.TableGenerator"/> 
    </id> 

    <property name="code" unique="true" not-null="true"/> 
    <property name="description" not-null="true"/> 

    <map name="localizedDescriptions" lazy="false"> 
     <key property-ref="code" column="code"/> 
     <index column="locale" type="locale"/> 
     <element column="description" type="string" not-null="true"/> 
    </map> 

    <union-subclass name="B"/> 
    <union-subclass name="C"/> 

B와 C 데이터베이스 테이블에는 필드 ID, 코드 및 설명을 예상대로. 그러나 b_localized_descriptions 또는 c_localized_descriptions 테이블은 없지만 a_localized_descriptions 테이블이 있습니다. 이것은 원하는 테이블이 아닙니다. 그래서 모든 서브 클래스에 대해 맵을 정의 할 필요없이 원하는 동작을 가질 수 있습니까?

답변

0
<union-subclass name=”C”> 
<property name=”salary” column=”SALARY” /> 
<property name=”bonus” column=”BONUS” /> 
</union-subclass> 

포함시킬 유니온 서브 클래스 xml 태그 내의 속성을 지정하십시오.

+0

음, 내 질문에 "모든 하위 클래스에 대해지도 [및 공통 속성]을 정의하지 않고도" –

관련 문제