Используйте Hibernate Session Factory вместо Hibernate Template как:
public abstract class HomeSessionFactory {
@Autowired
protected SessionFactory sessionFactory;
}
расширить этот класс в вашем файле xxDAOImpl как.
@Repository("LoginDetailsDAO")
@Transactional
public class LoginDetailsDAOImpl extends HomeSessionFactory implements LoginDetailsDAO {
@SuppressWarnings("unchecked")
@Transactional(readOnly = true)
public List<UserLogin> loginDetails(UserLogin login) {
Session session = sessionFactory.openSession();
Transaction transaction = session.beginTransaction();
List<UserLogin> result = session.createQuery("from UserLogin").list();
transaction.commit();
return result;
}
}
Файл контекста Spring:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>com.home.app.model.UserLogin</value>
</list>
</property>
</bean>
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>properties/database.properties</value>
</property>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>