On Jun 10, 2011, at 11:32 AM, Thiago H. de Paula Figueiredo wrote:
> On Fri, 10 Jun 2011 12:12:01 -0300, Tony Nelson <[email protected]> wrote:
>
>> So maybe I should have sent this question to the Spring list?
>
> If you're not using Tapestry-Hibernate this question went to the wrong list.
> :)
>
Indeed it was a Spring related issue. Doing some more searching I found that
Spring requires @Transactional now, and I had only added my data access tier.
Creating a quick business tier and marking the interface @Transactional solved
the problem. For anyone that may find this in [insert favorite search engine]
later:
My interface for my business class:
package com.starpoint.helpdesk.business;
import com.starpoint.helpdesk.domain.Office;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Transactional(readOnly = true)
public interface OfficeLogic {
List<Office> getAllOffices();
}
The page was of course updated to call this method instead of the DAO directly.
The updated applicationContext.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"
default-autowire="byName" >
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="${dataSource.driverClass}" />
<property name="username" value="${dataSource.user}" />
<property name="password" value="${dataSource.password}" />
<property name="url" value="${dataSource.jdbcURL}" />
</bean>
<!-- Hibernate session factory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:/hibernate.cfg.xml"/>
</bean>
<!-- Hibernate transaction manager -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<context:component-scan base-package="com.starpoint.helpdesk.dao" />
<context:component-scan base-package="com.starpoint.helpdesk.business" />
<context:annotation-config/>
<tx:annotation-driven transaction-manager="transactionManager" />
</beans>