Hello Sir,
I think I get what you mean, but Im not sure how to do it. I have setup my hibernate-spring like this:
hibernate.cfg.xml:
PHP Code:
.....
<session-factory>
<property name="connection.username">root</property>
<property name="connection.url">jdbc:mysql://localhost:3306/crown</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="myeclipse.connection.profile">MySQL</property>
<property name="connection.password"></property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.autocommit">true</property>
<!-- Connection Pooling config, using cp30 -->
<property name="hibernate.c3p0.max_size">5</property>
<property name="hibernate.c3p0.min_size">1</property>
<property name="hibernate.c3p0.timeout">5000</property>
<property name="hibernate.c3p0.max_statements">0</property>
<property name="hibernate.c3p0.acquire_increment">3</property>
<property name="hibernate.c3p0.idle_test_period">300</property>
<mapping class="model.Customers" />
<mapping class="model.AccountInfo" />
<mapping class="model.CreditLogs" />
......
</session-factory>
and my applicationContext.xml like this:
PHP Code:
<!-- hibernate specific configuration -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cfg.xml" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="daoInterface" class="dao.implementations.SampleDaoImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="serviceInterface" class="service.implementations.SampleServiceImpl">
<property name="daoInterface" ref="daoInterface" />
</bean>
and my action class (or controller) will call service.save(object). service is instance of serviceInterface and save is a method of serviceInterface. Here is my sample code on SampleServiceImpl which implements serviceInterface.
PHP Code:
public class SampleServiceImpl implements ServiceInterface {
private DaoInterface daoInterface;
//setters
public Object save(Object o) {
dao.save(o);
// some logic to create an ActionLog object.
dao.save(actionLog);
}
}
will this set up do? like when some logic to create an ActionLog object throws an exception, the transaction is rolled back? im not sure if my setup is transactional.
thank you,.
-marckun