mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-09 04:34:49 +00:00
revised usertype sect
git-svn-id: https://svn.jboss.org/repos/hibernate/trunk/Hibernate3/doc@5577 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
fab3331333
commit
e3bfdf4ec6
@ -2622,36 +2622,45 @@
|
|||||||
Notice the use of <literal><column></literal> tags to map a property to multiple
|
Notice the use of <literal><column></literal> tags to map a property to multiple
|
||||||
columns.
|
columns.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
You may also supply parameters to a UserType in the mapping file. To do this, your UserType
|
The <literal>CompositeUserType</literal>, <literal>EnhancedUserType</literal>,
|
||||||
has to implement the <literal>org.hibernate.usertype.ParameterizedType</literal> interface.
|
and <literal>UserCollectionType</literal> and <literal>UserVersionType</literal>
|
||||||
To supply parameters to your UserType, you can use the <literal><type></literal> element
|
interfaces provide support for more specialized uses.
|
||||||
in your mapping files.
|
|
||||||
</para>
|
</para>
|
||||||
<programlisting><![CDATA[<property name="primitiveWithNullValues" column="INT_COLUMN">
|
|
||||||
<type name="org.hibernate.test.typeparameters.NullMappingType">
|
<para>
|
||||||
<param name="default">1</param>
|
You may even supply parameters to a <literal>UserType</literal> in the mapping file. To
|
||||||
|
do this, your <literal>UserType</literal> must implement the
|
||||||
|
<literal>org.hibernate.usertype.ParameterizedType</literal> interface. To supply parameters
|
||||||
|
to your custom type, you can use the <literal><type></literal> element in your mapping
|
||||||
|
files.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<programlisting><![CDATA[<property name="priority">
|
||||||
|
<type name="com.mycompany.usertypes.DefaultValueIntegerType">
|
||||||
|
<param name="default">0</param>
|
||||||
</type>
|
</type>
|
||||||
</property>]]></programlisting>
|
</property>]]></programlisting>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The UserType can now retrieve the value for the parameter named <literal>default</literal>
|
The <literal>UserType</literal> can now retrieve the value for the parameter named
|
||||||
from the Properties object passed to it.
|
<literal>default</literal> from the <literal>Properties</literal> object passed to it.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
If you use a certain UserType very often, it may be useful to define a shorter name for it.
|
If you use a certain <literal>UserType</literal> very often, it may be useful to define a
|
||||||
You can do this using the <literal><typedef></literal> element in your mapping files.
|
shorter name for it. You can do this using the <literal><typedef></literal> element.
|
||||||
Typedefs contain a UserType and a defined name for it, and may also contain a list of default
|
Typedefs assign a name to a custom type, and may also contain a list of default
|
||||||
paramter values if the type defined implements <literal>ParameterizedType</literal>. After
|
parameter values if the type is parameterized.
|
||||||
defining the name, it can be used everywhere the original classname can be used.
|
|
||||||
</para>
|
</para>
|
||||||
<programlisting><![CDATA[<typedef class="org.hibernate.test.typeparameters.NullMappingType" name="nullMapper">
|
|
||||||
<param name="default">2</param>
|
<programlisting><![CDATA[<typedef class="com.mycompany.usertypes.DefaultValueIntegerType" name="default_zero">
|
||||||
</typedef>
|
<param name="default">0</param>
|
||||||
|
</typedef>]]></programlisting>
|
||||||
|
|
||||||
|
<programlisting><![CDATA[<property name="priority" type="default_zero"/>]]></programlisting>
|
||||||
|
|
||||||
<property name="primitiveWithNullValues" column="INT_COLUMN">
|
|
||||||
<type name="nullMapper"/>
|
|
||||||
</property>]]></programlisting>
|
|
||||||
<para>
|
<para>
|
||||||
It is also possible to override the parameters supplied in a typedef on a case-by-case basis
|
It is also possible to override the parameters supplied in a typedef on a case-by-case basis
|
||||||
by using type parameters on the property mapping.
|
by using type parameters on the property mapping.
|
||||||
@ -2669,10 +2678,6 @@
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|
||||||
<para>
|
|
||||||
TODO: document parameterizable usertypes
|
|
||||||
</para>
|
|
||||||
|
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user