We use Joda Time in the project, and all dates in @Entities are of type org.joda.time.DateTime. We use Joda-Hibernate user types for mapping it to DB.
BUT: I'm tired of declaring the field type on every such date:
Code:
@Type(type = "org.joda.time.contrib.hibernate.PersistentDateTime")
private DateTime actualStartDate;
@Type(type = "org.joda.time.contrib.hibernate.PersistentDateTime")
private DateTime actualEndDate;
@Type(type = "org.joda.time.contrib.hibernate.PersistentDateTime")
private DateTime plannedStartDate;
...
From what I've found, I can declare global alias using @TypeDef, than I could make it a bit shorter, e. g.:
Code:
@Type(type = "persistentDateTime")
private DateTime actualStartDate;
@Type(type = "persistentDateTime")
private DateTime actualEndDate;
@Type(type = "persistentDateTime")
private DateTime plannedStartDate;
...
But still it's horrendous amount of pointless code. How can I globally tell Hibernate "use this user type converter for fields of that type"? So that I finish with:
Code:
private DateTime actualStartDate;
private DateTime actualEndDate;
private DateTime plannedStartDate;
...
I can't find a way to do it... but it's crazy too much to assume it can't be done...