[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3172) There should be a way to add a Serializable object that represents the user that is using the current session
Will Hoover (JIRA)
noreply at atlassian.com
Tue Mar 11 07:26:33 EDT 2008
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_29756 ]
Will Hoover commented on HHH-3172:
----------------------------------
I should have been more clear in my explanation. What I am looking for is a facility to add properties to the Session such as a "user". Hiberante does not need to be aware of the "user" concept, but rather facilitate a means to store Session properties in general. Right now there is no way to extend the Hibernate Session/SessionFactory. What I'm proposing is:
1) Add a simple hash map where Session level properties can be stored/retrieved OR
2) Provide a way to extend the Session/SessionFactory so that properties that belong in the Session can be stored/retrieved.
> 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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list