hibernate - 我可以在 grails 中获取当前使用的 hibernate 方言吗?

标签 hibernate grails

我在我的应用程序中使用 grails 2.3.11。

我可以在运行时获取当前使用的数据源方言吗?

我只需要检查我使用的数据库类型(oracle 或 H2)。

谢谢!

最佳答案

是的,您可以调用getDialect() SessionFactory 中的方法。在服务或任何地方依赖注入(inject) bean:

def sessionFactory

然后可以使用当前的方言实例
Dialect dialect = sessionFactory.dialect

关于hibernate - 我可以在 grails 中获取当前使用的 hibernate 方言吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37816986/

相关文章:

hibernate - 是否可以在Grails 3中读取和写入不同的数据源URL?

java - 在 hql 中运行查询时出现语法错误

grails - Grails 2.2.2 createCriteria抛出错误

date - 在 Grails Prod 应用程序上遇到错误的日期

grails - grails中根据父属性对查询结果进行排序

java - Hibernate 动态每行结果数

java - 使用 Spring MVC 3 + Hibernate 更新持久对象的 "correct"或 "safe"方法是什么?

hibernate - 在实体类中添加toString方法的JPA : java. lang.StackOverflowError

performance - grails 从 CDN 提供 index.html

grails - 有没有办法用 mongodb 控制 gorm 中的加载关系?