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;

?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top