[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

Emmanuel Bernard (JIRA) noreply at atlassian.com
Tue Mar 11 13:13:33 EDT 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_29761 ] 

Emmanuel Bernard commented on HHH-3172:
---------------------------------------

Ah. That's a concept that we have discussed in the past (for the session factory). Steve is not really convinced though.

> 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