First I'd like to say that I've never used Hibernate 2 , only the hibernate 3 but the code that is been generated is just fine.
When you are declaring a property to be of some custom type - in this case
Quote:
com.company.hibernate.usertypes.LastModifiedColumnType
then the natural thing Hibernate to do is to present this property as
Quote:
com.company.hibernate.usertypes.LastModifiedColumnType
.
Now you have to have another class perhaps named as
Quote:
com.company.hibernate.usertypes.LastModifiedColumnTypeUserType
this class is reqiured to provide the custom persistent for
Quote:
com.company.hibernate.usertypes.LastModifiedColumn
So when Hibernate sees property of (your) type
Quote:
com.company.hibernate.usertypes.LastModifiedColumnType
then it will invoke
Quote:
com.company.hibernate.usertypes.LastModifiedColumnTypeUserType
methods for storing and retrival of the data.
so the default-value should be
Quote:
new com.company.hibernate.usertypes.LastModifiedColumnType()
and inside this default constructor you may initialize the inner date field to
Quote:
java.util.Date
I'm not quite sure about the implementation of this custom type so I'm gussing here.
Of course the generated code then will be
Quote:
protected LastModifiedColumnType lastModified = new LastModifiedColumnType();
Some other dependent codes that expect the lastModified to be
Quote:
java.util.Date
- you have two options here -
1) to change all client code that depends on this property as
Quote:
java.util.Date
object or
2) to make the
Quote:
LastModifiedColumnType
to extend the
Quote:
java.util.Date
class (I personally do not recomend this sort of patches but this of course depends on some other factors so it is really up to you what decision to make)