Question

We are using Hibernate 3.6.x and Joda-time, persisting DateTime with a org.jadira.usertype.dateandtime.joda.PersistentDateTimeWithZone like so:

@Columns(columns = {
        @Column(nullable = false, name = "requestedOn"),
        @Column(nullable = false, name = "requestedOnTZ") })
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTimeWithZone")
private DateTime requestedOn;

Is there a way to hook into Hibernate in order to hide the annotations above behind one annotation, like:

@DateTimeWithZone(time = "requestedOn", zone = "requestedOnTZ")
private DateTime requestedOn;

?

Was it helpful?

Solution

I don't think you can. Those are standard annoatations that the API expects to find while processing your code (scanning for annotations in this case. You can hack your hibernate and modify it's annotation scanner to take into account a custom annotation you've made, but this will spell trouble later when you want to migrate to a newer version of Hibernate.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top