开发者

Using restriction of Criteria API in hibernate for Date

开发者 https://www.devze.com 2023-02-16 20:07 出处:网络
The situation is like this. The format of the date in SQL server is different from oracle. In SQL server it is stored as TimeStamp. How doe开发者_运维问答s Restriction.eq , Restriction.lt, Restriction

The situation is like this. The format of the date in SQL server is different from oracle. In SQL server it is stored as TimeStamp. How doe开发者_运维问答s Restriction.eq , Restriction.lt, Restriction.gt work on Date objects ? Is there any way to just use date and not the time ?


According to this answer, you can use Restriction.ltProperty and related restrictions on date fields and Hibernate will do its best to parse them.

In case this approach should not work, you can always write your restrictions in native SQL using Restrictions.sqlRestriction.

0

精彩评论

暂无评论...
验证码 换一张
取 消