Hello all...
I am trying to develop an application using Spring & Hibernate, but seem to be doing something wrong. I have tried searching the forum but have not found what I was missing... here is the whole story..
1. I created a DAO with @Transactional Attribute as follows
where getSession is a helper method...Code:@Transactional(readOnly = true, isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRES_NEW) public List<E> findAll() { return this.getSession().createQuery("from " + this.entityClass.getName()).list(); }
2. In my configuration... I haveCode:public Session getSession() { if ((this.sessionFactory == null) || this.sessionFactory.isClosed()) { throw new IllegalAccessError( "Session Factory is either not initialized or is closed"); } return this.sessionFactory.getCurrentSession(); }
It looks as though I am missing something really basic... Any suggestions?Code:<tx:annotation-driven transaction-manager="txManager"/> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/> <jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/bvdb"/> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="packagesToScan" value="com.company.model" /> <property name="hibernateProperties"> <value> hibernate.dialect=org.hibernate.dialect.Oracle10gDialect hibernate.current_session_context_class=org.springframework.orm.hibernate3.SpringSessionContext hibernate.show_sql=true </value> </property> </bean>


Reply With Quote
