I didn't see the need for a cocoon component. I looked again, but still can't find the article that got me going... basically here is my setup:

web.xml:

<!-- Location of the application context configuration file -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>WEB-INF/ApplicationContext.xml</param-value>
    </context-param>

<!-- Filter Configuration ========================================== -->
    <filter>
        <filter-name>OpenSessionInViewFilter</filter-name>

<filter-class>org.springframework.orm.hibernate.support.OpenSessionInViewFilter</filter-class>
        <init-param>
            <param-name>singleSession</param-name>
            <param-value>false</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>OpenSessionInViewFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

<!-- Listener Configuration ========================================== -->
    <listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

Applicationcontext.xml:

<beans>
<!-- The data source -->
<bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="DataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://dbplace.com/db</value>
</property>
<property name="username">
<value>dbuser</value>
</property>
<property name="password">
<value>dbpas</value>
</property>
</bean>


<!-- The transaction manager -->
<bean class="org.springframework.orm.hibernate.HibernateTransactionManager" id="transactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>


<!-- The session factory -->
<bean class="org.springframework.orm.hibernate.LocalSessionFactoryBean" id="sessionFactory">
<property name="mappingResources">
<list>
<!-- Authenticator Mapping -->
<value>com/kismetsoftware/authenticator/model/User.hbm.xml</value>
<value>com/kismetsoftware/authenticator/model/Role.hbm.xml</value>


</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">net.sf.hibernate.dialect.MySQLDialect</prop>
</props>
</property>
<property name="dataSource">
<ref bean="DataSource"/>
</property>
</bean>



<!-- Authenticator Beans -->
<bean class="com.kismetsoftware.authenticator.spring.dao.hibernate.UserHibernateDAO" id="userDAO">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>


<bean class="com.kismetsoftware.authenticator.spring.dao.hibernate.RoleHibernateDAO" id="roleDAO">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>


<bean class="com.kismetsoftware.authenticator.spring.service.AuthenticatorServiceImpl" id="authenticatorServiceTarget" init-method="initialize">
<property name="userDAO">
<ref bean="userDAO"/>
</property>
<property name="roleDAO">
<ref bean="roleDAO"/>
</property>
</bean>


<bean class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" id="authenticatorService">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="target">
<ref bean="authenticatorServiceTarget"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="create*">PROPAGATION_REQUIRED</prop>
<prop key="read*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="initializeDatabase">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>


</beans>

So in flow, you just get a handle on the service beans, which handle all the work, and lazy initialization is no longer an issue.

JD


Jakub Kaniewski wrote:
Brent Johnson wrote:

I searched the Wiki for "servletfilter", "servlet-filter", "servlet
filter" and didn't find anything. Is there an example of closing
Hibernate sessions using a servlet filter on the Wiki?


Here is the wiki article I mentioned before - http://wiki.apache.org/cocoon/CocoonAndHibernateTutorial?highlight=%28Hibernate%29


J.K.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to