问题
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.program
and 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