Hello all,
I'm new in spring, i try learn a simple application with spring and hibernate. But i confuse with occurs exception.
Code:
org.hibernate.HibernateException: load is not valid without active transaction
	org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:297)
	$Proxy58.load(Unknown Source)
	impl.PersonImpl.getById(PersonImpl.java:48)
	controller.PersonFormController.displayForm(PersonFormController.java:36)
	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	java.lang.reflect.Method.invoke(Method.java:597)
	org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:160)
	org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:245)
	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:874)
	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:808)
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:431)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
This my ApplicationContext.xml
Code:
<?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:p="http://www.springframework.org/schema/p"
	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-2.5.xsd
				http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
                http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">


    <context:property-placeholder location="/WEB-INF/jdbc.properties"/>
    <context:component-scan base-package="impl" />
    <context:annotation-config/>

    <bean id="dataSource"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource"
          p:driverClassName="${jdbc.driver}"
          p:url="${jdbc.url}"
          p:username="${jdbc.username}"
          p:password="${jdbc.password}" />


    <bean
        id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
        <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration"/>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${hibernate.dialect}</prop>
                <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
            </props>
        </property>
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>
    </bean>
</beans>
This my Repository
Code:
@Repository("personImpl")
@Transactional(readOnly = true)
public class PersonImpl implements PersonDao {

    private SessionFactory sessionFactory;

    @Autowired
    public void setSessionFactory(SessionFactory sessionFactory) {
        this.sessionFactory = sessionFactory;
    }
    
    public Person getById(Long id) {
        String hql = "from Person p where id=:id";
        return (Person) sessionFactory.getCurrentSession().load(Person.class, id);
}
I try to solved this problem but i can't...please ..
what is my code available incorrect one ? Or my configuration is wrong ?
Thanks for your attention...