Moj xml springowy:
<context:annotation-config />
<context:component-scan base-package="temp.dao" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
...
</bean>
<tx:annotation-driven />
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory" />
</bean>
<bean id="hibernate4AnnotatedSessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
...
</list>
</property>
<property name="hibernateProperties">
<props>
...
</props>
</property>
</bean>
Przykladowe dao z pakietu temp.dao:
@Component
public class ADAOImpl
implements ADAO
{
private SessionFactory sessionFactory;
public void setSessionFactory(SessionFactory sessionFactory)
{
this.sessionFactory = sessionFactory;
}
@Override
@Transactional
public void save(B b)
{
Session session = this.sessionFactory.getCurrentSession(); //sessionfactory jest nullem
session.persist(b);
}
nie wiem jakiej konstrukcji uzyc aby do tego dao wstrzyknac te seesion factory z xml...