There should be a way to add a Serializable object that represents the user that is using
the current session
-------------------------------------------------------------------------------------------------------------
Key: HHH-3172
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3172
Project: Hibernate3
Issue Type: Bug
Components: core
Environment: N/A
Reporter: Will Hoover
There should be a way to add a Serializable object that represents the user that is using
the current session. The only way to do this now is:
Interceptor interceptor = new MyInterceptor();
Session session = factory.openSession(interceptor);
interceptor.setSession(session);
interceptor.setUserId(user.getId());
Should be:
Serializable user = ...
Session session = factory.openSession(user);
An alternative and more flexible solution would be to allow the session to be customized.
Currently the org.hibernate.Configuration instantiates the factory implementation (if this
is done- not sure why it is interfaced to begin with). This is repeated in session factory
implementation as well:
public SessionFactory buildSessionFactory() throws HibernateException {
...
// why not overload the build method and allow impl to be passed if desired?
return new SessionFactoryImpl(
this,
mapping,
settings,
getInitializedEventListeners()
);
}
private SessionImpl openSession(
Connection connection,
boolean autoClose,
long timestamp,
Interceptor sessionLocalInterceptor
) {
// why not overload the open session method and allow impl to be passed if desired?
return new SessionImpl(
connection,
this,
autoClose,
timestamp,
sessionLocalInterceptor == null ? interceptor : sessionLocalInterceptor,
settings.getDefaultEntityMode(),
settings.isFlushBeforeCompletionEnabled(),
settings.isAutoCloseSessionEnabled(),
settings.getConnectionReleaseMode()
);
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira