Here is my code
Code:
public class VarCharString implements UserType, ParameterizedType {
   private int length;
   public void setParameterValues(Properties parameters) {
        length = Integer.parseInt(parameters.getProperty("length"));
   } 
   ...............
}
and here is my mappings
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
   <typedef name="FirstName"
      class="default.VarCharString">
      <param name="length">30</param>
      </typedef>
   <!-- rename class to student card -->
    <class name="default.Student" table="studentcard" schema="public" lazy="false">
        <property name="firstname" type="FirstName">
            <column name="firstname" length="30" />
        </property>
        <property name="middlename" type="string">
            <column name="middlename" length="40" />
        </property>
        <property name="lastname" type="string">
            <column name="lastname" length="50" />
        </property>
   </class>
</hibernate-mapping> 
The question is: should I define
Code:
<typedef name="MiddleName"
      class="default.VarCharString">
      <param name="length">40</param>
      </typedef>
and
Code:
   <typedef name="LastName"
      class="default.VarCharString">
      <param name="length">50</param>
      </typedef>
or there is a way to force ParameterizedType.setParameterValues() to "read" length param from here
Code:
        <property name="firstname" type="FirstName">
            <column name="firstname" length="30" />
        </property>
maybe there are some other ways to slove this problem?