Me using spring-framework-1.2.1 + hibernate-3.0
I am trying to perform a login using spring + hibernate and get this exception; I did find a couple of threads with this problem , but none matched
SEVERE: Could not complete request
org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
at org.springframework.orm.hibernate3.LocalSessionFac toryBean$TransactionAwareInvocationHandler.invoke( LocalSessionFactoryBean.java:948)
at $Proxy0.getCurrentSession(Unknown Source)
The code is use to perform the login is
Criterion idCriterion = Expression.eq("userID",new Integer(userID));
Criterion pwdCriterion = Expression.eq("password",password);
Criteria loginCriteria = this.sessionFactory.getCurrentSession().createCrit eria(User.class);
loginCriteria.add(idCriterion);
loginCriteria.add(pwdCriterion);
user = (User)loginCriteria.uniqueResult();
My DAO beans are defined as
<beans>
<!-- Data source bean -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value></property>
<property name="url">
<value>jdbc:mysql://localhost:3306/esimsdb</value></property>
<property name="username"><value>esims</value></property>
<property name="password"><value>esims</value></property>
</bean>
<!-- Spring's wrapper around Hibernate-->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
<property name="dataSource">
<ref local="dataSource"/>
</property>
<property name="mappingResources">
<list>
<value>org/esims/auth/model/User.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQ LDialect</prop>
</props>
</property>
</bean>
<!-- The bean that does the authentication using hibernate -->
<bean id="authDAOBean" class="org.esims.auth.dao.HibernateAuthDAO">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
</beans>
Thnx


Reply With Quote