Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

Name

Hibernate Core Session Plugin for Struts 2

Publisher

José Yoshiriro Image Added

License

Open Source (ASL2)

Version

1.0

Compatibility

Struts 2.0.9+

Homepage

http://code.google.com/p/hibernatesession-plugin-for-struts2/

Download

http://code.google.com/p/hibernatesession-plugin-for-struts2/downloads/list

Wiki Markup{rate:title=Rating|theme=dynamic|key=hibernatesessionpluginforstruts2}

Overview

Hibernate Session Plugin for Struts 2 INLINE

ExcerptThere is the best practice the use of design pattern "open session in view" for WEB applications with Hibernate.

...

Features

...

  • Interceptor for "open session in view" pattern with Hibernate

Usage

The Interceptor class is com.googlecode.s2hibernate.struts2.plugin.s2hibernatesession.HibernateSessionInterceptor.

Parameters:

  • sessionFactoryClass- Project Hibernate Session Factory
    Example: com.myproject.hibernate.HibernateSessionFactory?
  • sessionSource - Getter in the class named in sessionFactoryClass that returns a Hibernate Sessoin
    Example: session (indicates the getSessao() method)
  • target - Target object in Action
    Examples: hibernateSession; facade.hibernateSession
  • staticGetSessionMethod - Is the method named in sessionSource static?. Optional. Default true.
  • closeSessionAfterInvoke - Close the Hibernate Session after Action invokation? Optional. Default true.

Example

Code Block

Example 1:
<package name="principal" extends="struts-default" namespace="/">
    	<interceptors>
    		<interceptor name="hibernateInterceptor" class="com.googlecode.s2hibernate.struts2.plugin.s2hibernatesession.HibernateSessionInterceptor">
	    		<param name="target">facade.session</param>
	    		<param name="sessionFactoryClass">hibernate.factory.HibernateSessionFactory</param>
	    		<param name="sessionSource">session</param>
	    		<param name="staticGetSessionMethod">true</param>
	    		<param name="closeSessionAfterInvoke">true</param>
    		</interceptor>
    	</interceptors>

        <action name="teste" class="actions.TestAction">
	    	<interceptor-ref name="hibernateInterceptor"/>
        	<result>/resultpage.jsp</result>
        </action>

 </package> 
 Example 2: <package name="principal" extends="struts-default" namespace="/">
    	<interceptors>
    		<interceptor name="hibernateInterceptor" class="com.googlecode.s2hibernate.struts2.plugin.s2hibernatesession.HibernateSessionInterceptor">
	    		<param name="target">facade.session</param>
	    		<param name="sessionFactoryClass">hibernate.factory.HibernateSessionFactory</param>
	    		<param name="sessionSource">session</param>
    		</interceptor>

		<interceptor-stack name="basicStackWithHibernateSession">
				<interceptor-ref name="hibernateInterceptor"/>
				<interceptor-ref name="basicStack"/>
		    </interceptor-stack>

		    <interceptor-stack name="defaultStackWithHibernateSession">
				<interceptor-ref name="hibernateInterceptor"/>
				<interceptor-ref name="defaultStack"/>
		    </interceptor-stack>
    	</interceptors>

	<action name="enterData" class="actions.TestAction">
	    	<interceptor-ref name="basicStackWithHibernateSession"/>
        	<result>/inputpage.jsp</result>
        </action>

        <action name="submitData" class="actions.TestAction" method="doit">
	    	<interceptor-ref name="defaultStackWithHibernateSession"/>
        	<result>/resultpage.jsp</result>
        </action>

    </package>

Installation

& Usage

Google Code Wiki

Examples

Google Code Examples Download

Installation

Copy This plugin can be installed by copying the plugin jar into your application's /WEB-INF/lib directory. No other files need to be copied or created.

Version History

Version

Date

Author

Notes

1.5c

Dec 03, 2008

Image Added

Multiple XML packages extend and super class targets for Hibernate Session allowed

1.5b

Oct 24, 2008

Image Added

Wildcard allowed for Hibernate Session Target

1.5

Oct 21, 2008

Image Added

Configuration Constants by Project

1.0

Oct 08, 2008

José Yoshiriro Image Added

Initial release