Hibernate 4.3.5忽略v $ session.program配置属性 [英] Hibernate 4.3.5 ignores v$session.program configuration property

查看:235
本文介绍了Hibernate 4.3.5忽略v $ session.program配置属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前使用hibernate 3.2和boneCP,但我刚刚升级到hibernate 4.3.5和Hikari连接池连接我的java应用程序到我的oracle数据库。我设置v $ session.program到我想要的程序名称,并将其添加到hibernate配置。

I previously used hibernate 3.2 and boneCP but I just upgraded to hibernate 4.3.5 and the Hikari connection pool to connect my java application to my oracle database. I set v$session.program to the program name I want and add it to the hibernate configuration.

我创建了自己的hibernate配置类,扩展了由hibernate提供的 Configuration 类。

I've created my own hibernate configuration class that extends the Configuration class provided by hibernate.

public class MyConfiguration extends Configuration {
    private static final long serialVersionUID = 1L;

    public MyConfiguration() { }

    public MyConfiguration(SettingsFactory settingsFactory) {
        super(settingsFactory);
    }

    @Override
    public SessionFactory buildSessionFactory() throws HibernateException {
        ServiceRegistry registry = new StandardServiceRegistryBuilder()
        .applySettings(getProperties()).build();
        return new MySessionFactory(super.buildSessionFactory(registry));
    }
}

MySessionFactory 是一个SessionFactory的自定义包装器,通过反射使用SessionImpl的persistenceContext字段(这应该是问题,因为它在升级前也工作)。

The MySessionFactory is a custom wrapper for the SessionFactory that does some magic via reflection with the persistenceContext field of the SessionImpl (that should be the problem though because it worked before the upgrade, too).

然后我调用

Document configDocument = loadHibernateConfigruationDocument();
MyConfiguration conf = new MyConfiguration();
conf.configure(configDocument);
conf.buildSessionFactory();

然而,如果我去数据库(当应用程序运行时)和查询

However if I go to the database (while the application is running) and query

SELECT MACHINE, PROGRAM, USERNAME, count(*) as COUNT FROM v$session GROUP BY MACHINE, PROGRAM, USERNAME;

我找不到刚开始的程序。任何想法我做错了什么?

I can't find the program I just started. Any ideas what I'm doing wrong?

推荐答案

我找到了解决方案。我刚刚添加了 hibernate.hikari.dataSource.v $ session.program hibernate.hikari.dataSource.v $ session.username 我的配置和everthing工作正常。

I found the solution. I just added hibernate.hikari.dataSource.v$session.programand hibernate.hikari.dataSource.v$session.username to my configuration and everthing worked fine.

这篇关于Hibernate 4.3.5忽略v $ session.program配置属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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