]
Will Hoover commented on HHH-3172:
----------------------------------
Does Steve specify why is he not convinced?
It makes sense to be able to extend the Session/SessionFactory. Most frameworks that have
a concept of a session allow customization of that session either by providing a means to
extend it or by providing a mechanism to store data in it. Is there a separate Jira issue
that addresses this that you are aware of (I could not find one when I did a search)?
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: