MSSQL 2014错误的休眠方言

MSSQL 2014错误的休眠方言,第1张

MSSQL 2014错误的休眠方言

同时团队无法解决此问题,您可以创建一个自定义的方言解析器:

public class ScopeStandardDialectResolver implements DialectResolver {private static final long serialVersionUID = 1L;    @Override    public Dialect resolveDialect(DialectResolutionInfo info) {        Dialect customDialectResolver = customDialectResolver(info);        Log.getInstance().logInfo(Thread.currentThread().getStackTrace(), customDialectResolver.getClass().getName());        return customDialectResolver;    }    private Dialect customDialectResolver(DialectResolutionInfo info) {        final String databaseName = info.getDatabaseName();        final int majorVersion = info.getDatabaseMajorVersion();        if (isSqlServer2014(databaseName, majorVersion)) { return new SQLServer2012Dialect();         } else { return StandardDialectResolver.INSTANCE.resolveDialect(info);        }    }    private boolean isSqlServer2014(final String databaseName, final int majorVersion) {        return databaseName.startsWith("Microsoft SQL Server") && majorVersion == 12;    }}

然后,在持久性单元中进行配置:

<property name="hibernate.dialect_resolvers" value="com.oki.scope.hibernate.ScopeStandardDialectResolver" />

基于此示例:http : //blog.exxeta.com/2016/03/23/dynamically-resolve-
hibernate-database-dialect/



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5168897.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-18
下一篇 2022-11-18

发表评论

登录后才能评论

评论列表(0条)

保存