Hibernate version: 3.0
Name and version of the database you are using:MySQL
I am using hibernate3, EJB3.0 in jboss-4.0.3SP1. I want jta does all transaction. But, if my ejb cause an exception my hibernate update doesnt rollback.
I dont have any transaction control in my hibernate. and I get the session from session = getSessionFactory().getCurrentSession();
and I dont close session.
Here is my jboss-service.xml:
-------------------------------------
<server>
<mbean code="org.hibernate.jmx.HibernateService"
name="jboss.jca:service=HibernateFactory,name=HibernateFactory">
<depends>jboss.jca:service=RARDeployer</depends>
<depends>jboss.jca:service=LocalTxCM,name=MySqlDS</depends>
<attribute name="Datasource">java:/MySqlDS</attribute>
<attribute name="Dialect">org.hibernate.dialect.MySQLDialect</attribute>
<attribute name="JndiName">java:/hibernate/HibernateFactory</attribute>
<attribute name="SecondLevelCacheEnabled">true</attribute>
<attribute name="CacheProviderClass">org.hibernate.cache.EhCacheProvider</attribute>
<attribute name="ShowSqlEnabled">false</attribute>
<attribute name="TransactionStrategy">org.hibernate.transaction.JTATransactionFactory</attribute>
<attribute name="TransactionManagerLookupStrategy">org.hibernate.transaction.JBossTransactionManagerLookup</attribute>
<attribute name="FlushBeforeCompletionEnabled">true</attribute>
<attribute name="AutoCloseSessionEnabled">true</attribute>
<attribute name="UserTransactionName">java:/UserTransaction</attribute>
<attribute name="MapResources">
mappings/Users.hbm.xml,
mappings/UserTable.hbm.xml,
mappings/ZoneStates.hbm.xml
...
</attribute>
</mbean>
</server>
------------------------------------------------
And my stateless session bean is like this:
@Stateless
@Local(AdminInt.class)
public class AdminBean implements AdminInt{
...
-------------------------
and the method of ejb is like this:
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public boolean editBedType(BedType bedtype){
BedTypeDAO dao = new BedTypeDAO();
try {
dao.update(bedtype);
int i=100/0;//here I cause an exception. but the update doesnt rollback
} catch (Exception e) {
e.printStackTrace();
}
...
|