Is it possible to perform a request that checks the string representation of a Date instance. For example
Restrictions.like("dateField", "%12%")
to retrieve dates that either have String 12 in day or 12 in month or 12 in year where "dateField" is an instance of java.util.Date Thanks
I had the same problem and here's what I did:
First, I created my own Criterion implementation:
Then, I just use it when I put the Criteria together:
And that's about it. Note that this implementation is locale-dependent (pt_BR in this case) and works for postgresql, which has the to_char function. You might have to tweak it a little bit to work with your database engine.
Something like this
The part within the sqlRestriction depends on which database you are using.