所以我试图将鉴别器值赋予PesquisaFiltroGeral类中的字段属性:
<class name="PesquisaFiltroGeral" table="PESQUISA_FILTRO_GERAL" abstract="true">
<id name="id" column="ID">
<generator class="native"/>
</id>
<discriminator column="tipo" type="string"/>
<property name="fieldType" column="tipo" insert="false" update="false"/>
<subclass name="com.domain.entity.PesquisaFiltroProcess" discriminator-value="PROCESS_TYPE">
<property name="field" column="PROCFIELD">
<type name="org.hibernate.type.EnumType">
<param name="useNamed">true</param>
<param name="identifierMethod">getValue</param>
<param name="valueOfMethod">getFromValue</param>
<param name="enumClass">com.domain.enums.PesquisaFieldsProcesso</param>
</type>
</property>
</subclass>
<!--DOCUMENT FIELD - SUBCLASS 2-->
<subclass name="com.domain.entity.PesquisaFiltroDocument" discriminator-value="DOCUMENT_TYPE">
<property name="field" column="DOCFIELD">
<type name="org.hibernate.type.EnumType">
<param name="identifierMethod">getValue</param>
<param name="valueOfMethod">getFromValue</param>
<param name="enumClass">com.domain.enums.PesquisaFieldsDocumento</param>
</type>
</property>
</subclass>
</class>
但是当我尝试从db中获取此类型的对象时,fieldType为null。有什么理由吗?
答案 0 :(得分:0)
出于某种原因,将属性名称更改为与该列相同的属性:
<discriminator column="tipo" type="string"/>
<property name="tipo" column="tipo" insert="false" update="false"/>