[hibernate-dev] Fwd: [HV] Supporting Joda Time API with @Past/@Future

Gunnar Morling gunnar.morling at googlemail.com
Sun Apr 11 17:15:03 EDT 2010


Answers inline.

2010/3/30 Emmanuel Bernard <emmanuel at hibernate.org>

I like the idea.
> Initially we've decided to not add them and were waiting for the JSR-310.
> do you know the status and expected release?
>

JSR 310 was in Early Draft Review stage from 26 Feb till 28 Mar. It's
planned to be included in Java 7, though AFAIK it's not totally sure whether
this is really going to happen. As Joda is quite widely in use I think it
would be nice to have support for it in Hibernate Validator. Once JSR 310 is
final, support for it could be added to HV, and surely also to the BV spec.

>
> The main problem I see is that we would likely use the same annotations for
> both joda and the jsr-310.
> We could think of using @Constraint and use two validator implementations
> but unfortunately that would fail at runtime if we don't have Joda Time in
> the classpath.
>
> Anyone has an idea to work around that?
>

I thought about supporting the standard BV @Past/@Future annotations at
Joda/JSR 310 types with Hibernate Validator. In that case the validator(s)
for Joda/JSR 310 might be registered automatically by HV (as all validators
for annotations from the BV API), probably after some reflective checking
whether Joda/JSR 310 is present in the class path or not.

Alternatively one could provide one/two constraint-mapping XML file(s) to be
delivered with Hibernate Validator, which users might add to their
validation.xml in case they want to work with Joda/JSR 310.

The second approach is more in line with the concepts of customization
defined by BV, while the first is probably more comfortable for Hibernate
Validator users.


>
> On 24 mars 2010, at 22:40, Gunnar Morling wrote:
>
> > Hi,
> >
> > for Hibernate Validator 4.1 we are planning to add some new constraints.
> In
> > this context Hardy and I discussed whether it might be worth to add
> support
> > for the date/time types from the Joda Time API (
> > http://joda-time.sourceforge.net/) for the @Past/@Future standard
> > constraints.
> >
> > I think Joda is quite popular these days, and the upcoming JSR 310 is
> > heavily influenced by Joda, too (the spec lead is also the lead of Joda).
> So
> > this might add value for users, OTOH such support might be too specific.
> Are
> > there any opinions on this?
> >
> > Thanks, Gunnar
> > _______________________________________________
> > hibernate-dev mailing list
> > hibernate-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
>



More information about the hibernate-dev mailing list