Forgive me if this is too basic a question !
I also dont expect a free lunch or dont want to come across as someone who wants others to do my homework
I did google around and read details on SO also but I am really confused on this
Here is what I have working I just need to simply do a search and return results from the database
We are using weblogic and hence a managed environment which gives me connections
We have configured the session factory details like this :
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">MYDS</property>
<property name="show_sql">true</property>
<property name="default_schema">CLIENT1SCHEMA</property>
</session-factory>
</hibernate-configuration>
In my spring application context - have defined a sessionFactory and TransactionManager and then inject the session factory in my DAO
<bean id="sessionFactoryX" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:abc.hibernate.cfg.xml" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactoryX" />
</bean>
<bean id="myCustomDao" class="com.xyz.MyCustomDao" lazy-init="true">
<property name="criteriaConverter" ref="criteriaConverter" />
<property name="sessionFactory" ref="sessionFactoryX" />
</bean>
Now in my dao - I simply want to do a search - so here is what I have implemented :
public List<T> findAll(final HashMap param) {
List<T> listData = null;
Criteria subSelectCriteria =null;
try {
Session session=getSessionFactory().getCurrentSession();
subSelectCriteria =session.createCriteria(getType());
} catch (HibernateException e) {
e.printStackTrace();
}
boolean isDistinctQuery=false;
subSelectCriteria.setFirstResult(0);
subSelectCriteria.setMaxResults(100);
List inObjList = subSelectCriteria.list();
if(!inObjList.isEmpty()){
listData = inObjList;
}
return listData;
}
This all works fine and this above configuration was reached after facing a lot of issues related to Transaction management - which I had posted here : Transaction Management using Hibernate with weblogic
Now here is my basic question : I have no Transaction management code explicitly written : neither in my service layer via AOP nor @Transactional
It seems to work simply with the injection of :
org.springframework.orm.hibernate4.HibernateTransactionManager
So is this valid transaction management ?
I am trying to implement Multitenancy -as per earlier thread - but thats not my question here
Thanks