检索自动检测到的Hibernate方言 [英] Retrieve auto-detected hibernate dialect

查看:105
本文介绍了检索自动检测到的Hibernate方言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hibernate可以选择自动检测 hibernate.dialect 。我如何检索自动检测值?我无法找到任何关于此的信息。

解决方案

您可以从 SessionFactory ,但您需要将它转换为 SessionFactoryImplementor first:

  SessionFactory sessionFactory = ...; //你应该有这个引用
Dialect dialect =((SessionFactoryImplementor)sessionFactory).getDialect();

以上操作将通过会话工厂检索当前正在使用的方言实例 如果没有通过属性显式指定它,它就是自动检测到的实例。


Hibernate has the option to auto-detetect the hibernate.dialect. How can I retrieve that auto-detected value? I was unable to find any information on this.

解决方案

You can retrieve it from the SessionFactory but you'll need to cast it to SessionFactoryImplementor first:

SessionFactory sessionFactory = ...; // you should have this reference
Dialect dialect = ((SessionFactoryImplementor) sessionFactory).getDialect();

The above will retrieve the dialect instance currently being used by session factory, which is the auto detected instance if it wasn't explicitly specified via properties.

这篇关于检索自动检测到的Hibernate方言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆