开发者

Is it possible to map Hibernate <component> column to a custom user type?

I have defined a custom user type that works fine when used properties of my entities. For instance:

 <class name="com.my.sample" table="MY_TABLE">
    ...
    <property name="foo" type="myCustomUserType">
 </class>

I'm needing something like this:

 <class name="com.my.sample" table="MY_OTHER">
    ...
    <component name="myAddress" class="com.my.sample.Address">
       <property name="street" column="MY_OTHER_ADRR_STREET" 开发者_JAVA百科/>
       <property name="foo" type="myCustomUserType" column="MY_OTHER_ADRR_COLUMN" />
    </component>
 </class>

Obviously, I'm supposing that myCustomUserType is properly defined in the .HBM file. Is it possible to map a <component> property like this?


Actually, it works fine. It is also possible to map <component> properties using relationships such as <many-to-one>. The mapping was somethig like this:

<component name="myAddress" class="com.my.sample.Address" >
    <property name="aSimpleDate" column="TBL_ADDR_SIMPLE_DATE" type="date" />
    <many-to-one class="OtherClass" name="otherClass" >
        <column name="TBL_ADDR_OTHER_CLASS_ID" precision="9" scale="0"/>
    </many-to-one>
    <property name="foo" column="TLB_ADDR_FOO" type="myCustomUserType" />
</component>

Unfortunatelly, the Hibernate documentation is not very obvious about this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜