-->
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.  [ 1 post ] 
Author Message
 Post subject: transaction.rollback() doesn't rollback whole transaction
PostPosted: Thu May 01, 2008 3:59 pm 
Newbie

Joined: Thu May 01, 2008 3:17 pm
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

3.1.3

Mapping documents:

WorkSchedule.hbm.xml

<?xml version="1.0" encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="com.tzaconsulting.ptw.operations.common.po" >
<class name="WorkSchedule" table="work_schedule" >

<id name="workScheduleId" type="integer">
<column name="work_schedule_id" />
<generator class="increment"/>
</id>

<version name="concurrencyId" column="concurrency_id" type="integer"/>

|
|
|
|

<set name="assignmentsSet" inverse="true" cascade="all" order-by="sequenced_flag,status,adjusted_end_time">
<key column="work_schedule_id"/>
<one-to-many class="Assignments"/>
</set>

</class>

</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
I am using Microsoft SQL Server 2005 as the database.

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Problem: I have an object WorkSchedule which contains a set of Assignments (Refer to WorkSchedule.hbm.xml)
Suppose there are 4 assignments in this work schedule and first 3 are good assignments and the 4th
one is the bad one. Then the rollback should rollback all the assignments but it still saves the 3 good ones in
the database and just rollback the failed one.



The java caode for this is below:

public void saveWorkSchedule(WorkSchedule ws, Session session)
throws SystemException {

Transaction tx = null;
try{

tx = session.beginTransaction();
session.saveOrUpdate(ws);

tx.commit();
} catch (HibernateException e) {
tx.rollback();
SystemException exception = new SystemException(e.getMessage());
exception.fillInStackTrace();
throw exception;
} finally {
tx=null;
}
}



The hibernate configuratio is

?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="hibernate.session_factory_name">HibernateSessionFactory</property>
<property name="current_session_context_class">thread</property>
<property name="show_sql">false</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>

<!-- Mapping files -->

<mapping resource="com/tzaconsulting/ptw/common/po/Country.hbm.xml"/>
<mapping resource="com/tzaconsulting/ptw/common/po/PTWSysConfig.hbm.xml"/>

|
|
|

<!-- Mapping files -->
</session-factory>
</hibernate-configuration>

Read this: http://hibernate.org/42.html


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

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.