Hibernate 4.3.5 ignores v$session.program configuration property

懵懂的女人 提交于 2019-12-25 02:46:51

问题


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.

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));
    }
}

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).

Then I call

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?


回答1:


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.



来源:https://stackoverflow.com/questions/24058144/hibernate-4-3-5-ignores-vsession-program-configuration-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!