-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: transaction not rollback with CMT, SLSB and WebLogic6.1
PostPosted: Thu Feb 26, 2004 10:51 pm 
Newbie

Joined: Thu Feb 26, 2004 10:13 pm
Posts: 3
I am using Hivernate 2.0 and weblogic 6.1 sp1.
The hibernate.properties file:

hibernate.dialect=net.sf.hibernate.dialect.DB2Dialect
hibernate.connection.datasource=meta_db2
hibernate.show_sql=true
hibernate.transaction.factory_class=net.sf.hibernate.transaction.JTATransactionFactory
hibernate.transaction.manager_lookup_class=net.sf.hibernate.transaction.WeblogicTransactionManagerLookup

meta_db2 is an jndi datasource name registered in weblogic.

The mapping file for Task Entity:
<hibernate-mapping>
<class
name="com.volcano.metadata.model.TaskEntity"
table="ELEMENT_TASK"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="id"
column="id"
type="long"
>
<generator class="hilo">
</generator>
</id>
...
<set
name="taskParameters"
table="SCHEDULER_TASK_PARAMETER"
lazy="false"
inverse="false"
cascade="save-update"
sort="unsorted"
>

<key
column="TASK_ID"
/>
<composite-element class="com.volcano.metadata.model.TaskParameterEntity">

<many-to-one name="parameter"
class="com.volcano.metadata.model.ParameterEntity"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="PARAMETER_ID"
not-null="true"
/>
<property
name="sequence"
type="int"
update="true"
insert="true"
column="SEQUENCE"
/>

<property
name="parameterValue"
type="java.lang.String"
update="true"
insert="true"
column="PARAM_VALUE"
length="100"
/>
</composite-element>

</set>
...
</hibernate-mapping>

I need to delete a task for an id from a SLSB:
public void removeTask(long id ) throws
Exception {

Session session = null;
try {
session = sessionFactory.openSession();
Task task = ( Task )session.load( TaskEntity.class, new Long( id ) );
session.delete(task);
session.flush();
} catch( Exception e ) {
sessionContext.setRollbackOnly();
throw ...
} finally {
session.close();
}
}

When I delete a task which have several parameters, the hibernate first delete the relation table, and then delete the task table:

Hibernate: delete from SCHEDULER_TASK_PARAMETER where TASK_ID=?
Hibernate: delete from ELEMENT_TASK where id=?
16:19:59,000 WARN JDBCExceptionReporter:36 - SQL Error: -532, SQLState: 23504

An Exception occur when delete a task, then all parameters of the task in SCHEDULER_TASK_PARAMETER table will be delete!!! Why the transaction did not rollbak although i called sessionContext.setRollbackOnly() when catching Exception?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2004 11:13 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
This is certainly an issue with either your transaction demarcation or the definition of your data source.

Make sure, for example, that the driver is not set to specify connections as auto-commit. Make sure in the WL console that your "meta_db2" datasource is defined as a TxDataSource and not just a plain DataSource. Also, make sure that a transaction is actually in effect when entering this method.


Top
 Profile  
 
 Post subject: Thanks
PostPosted: Fri Feb 27, 2004 12:05 am 
Newbie

Joined: Thu Feb 26, 2004 10:13 pm
Posts: 3
I change the plain DataSource to TxDataSource. Then the transaction works correctly. Thanks for your reply so quick!!!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 27, 2004 7:44 am 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
steve wrote:
This is certainly an issue with either your transaction demarcation or the definition of your data source.

Make sure, for example, that the driver is not set to specify connections as auto-commit. Make sure in the WL console that your "meta_db2" datasource is defined as a TxDataSource and not just a plain DataSource. Also, make sure that a transaction is actually in effect when entering this method.


How do you define a datasource as a TxDataSource?
I'm using JBoss 3.2.3.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 28, 2004 5:29 am 
Newbie

Joined: Thu Feb 26, 2004 10:13 pm
Posts: 3
There are two kinds of datasource in WLS, one is plain DataSource, another is TxDataSource. Only TxDataSouce can participate in CMT. Maybe it is a specialization of WLS. I did not find that kind of DataSource in WebSphere too.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.