The class name containing SessionFactory
is DataProvider
and has the following implementation:
@Resource(name="sessionFactory")
protected SessionFactory factory;
protected Class<E> entity;
protected String tableName;
public DataProvider(Class e) {
this.entity = e;
this.tableName = entity.getAnnotation(Table.class).name();
}
@Transactional(readOnly = true)
public List<E> getAll() {
Session s = factory.getCurrentSession(); // A exceção acontece aqui.
return s.createQuery("FROM " + tableName ).list();
}
The bean with the SessionFactory
setting is:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="models"/>
<property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
I'm getting NullPointerException
on the commented line. The question is: am I doing something wrong or is there still some configuration?