这是我在 mysql 中的查询
SELECT DATEDIFF('2008-11-30','2008-11-29') AS DiffDate
如何转换为 Hibernate 查询语言
最佳答案
实现此目的的方法之一是扩展 mysql 方言并使用 registerFunction(String, SQLFunction)
注册它。
public class CustomMySQL5InnoDBDialect extends MySQL5InnoDBDialect {
public CustomMySQL5InnoDBDialect () {
super();
registerFunction( "datediff", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "datediff(?1, ?2)" ) );
}
}
关于java - hibernate : convert mysql Query Datedif to HQL Query,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13304802/