[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3174) Session/SessionFactory should be extendable or provide a mechanism to store session level data in it

Will Hoover (JIRA) noreply at atlassian.com
Thu Mar 13 08:35:33 EDT 2008


Session/SessionFactory should be extendable or provide a mechanism to store session level data in it
----------------------------------------------------------------------------------------------------

                 Key: HHH-3174
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3174
             Project: Hibernate3
          Issue Type: Improvement
          Components: core
    Affects Versions: 3.2.6
         Environment: N/A
            Reporter: Will Hoover


ISSUE:
Most frameworks that have a concept of a session that allow customization of that session either by providing a means to extend it or by providing a mechanism to store data in it. There are many cases where storing Session level data makes sense. 

EXAMPLE USE CASE:
For instance, if capture of the actual user that is using the Session is needed it makes sense that it resides as an attribute of the current Session that is being used by that user. An example of this would be an Audit Log/Trail that needs to capture who/what is using the current Session. The Hibernate documentation proposes to use an Interceptor for this by setting the user within it, but this is not the proper location to capture this data especially if multiple Interceptors are needed (which cannot be done currently- i.e. an audit log Interceptor and a security Interceptor- using listeners can work, but require the user to be set on each listener being used). If an Interceptor or listener were to hold the user we would lose the feature of obtaining the user if we didn't need the interceptor/listener in a project. It makes more sense to add the user to the session because it will be commonly used throughout the Session life-cycle.

PROPOSED RESOLUTION OPTION 1 (add simple HashMap in the session):
If the session contained a simple HashMap it would accommodate 99% of use cases where a session level attribute is needed.

PROPOSED RESOLUTION OPTION 2 (allow extension of Session/SessionFactory):
Currently the org.hibernate.Configuration has a method to buildSessionFactory(...) that instantiates a new instance of org.hibernate.impl.SessionFactoryImpl preventing the SessionFactory implementation from being defined. The org.hibernate.impl.SessionFactoryImpl also has a method to openSession(...) that instantiates a new instance of org.hibernate.impl.SessionImpl preventing the Session implementation from being defined. A possible solution would be to allow the implementation to be passed/proxy. 

-- 
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