-->
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.  [ 7 posts ] 
Author Message
 Post subject: Hibernate does not rollback super class entity tables
PostPosted: Fri Apr 20, 2012 5:45 pm 
Newbie

Joined: Fri Apr 20, 2012 5:32 pm
Posts: 4
Hi,

I am new to Hibernate. I am developing a domain model in which the inheritance type we are using is JOINED. I have defined unique constraints on the derived class entity.
When I create an object of the derived class and persist it twice, the second persist operation throwing unique constraint violation as expected. So I did not see the second record in the derived entity table. But surprisingly the parent entity table has got two rows.

I used transactions also, but at the time of transaction commit, it is detecting the constraint violation and rolling back only the derived entity changes but not the parent table.

Could someone please explain why this strange behavior?

thanks in advance.
-Madan


Top
 Profile  
 
 Post subject: Re: Hibernate does not rollback super class entity tables
PostPosted: Mon Apr 23, 2012 4:44 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
I suggest you to log all jdbc-activities using p6spy, and then please report the output.
It will help to analyze what's happening...


Top
 Profile  
 
 Post subject: Re: Hibernate does not rollback super class entity tables
PostPosted: Mon Apr 23, 2012 1:22 pm 
Newbie

Joined: Fri Apr 20, 2012 5:32 pm
Posts: 4
Thanks for the help. I tried to set the p6spy in my Jboss 7, but did not work properly. Getting the error saying that could not load the driver com.p6spy.engine.spy.P6SpyDriver.
I copied the p6spa.jar in to the JBOSS_HOME/standalone/lib directory. Also update the spy.properties. But no luck.

Could you please help in setting up the p6spy or any other alternate way to for SQL log.

thanks
Madan


Top
 Profile  
 
 Post subject: Re: Hibernate does not rollback super class entity tables
PostPosted: Mon Apr 23, 2012 1:25 pm 
Newbie

Joined: Fri Apr 20, 2012 5:32 pm
Posts: 4
here is my data source definition settings

<datasources>
<datasource jta="false" jndi-name="java:jboss/datasources/oracleDS" pool-name="java:jboss/datasources/oracleDS" use-ccm="false">
<connection-url>jdbc:oracle:thin:@ogo:1521:sioraprd</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<driver>ojdbc6.jar</driver>
<security>
<user-name>bollm1</user-name>
<password>bollm1</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
<background-validation-millis>0</background-validation-millis>
</validation>
<statement>
<prepared-statement-cache-size>0</prepared-statement-cache-size>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>

I replace the oracle driver class with p6spy driver, it is as follows:

<datasources>
<datasource jta="false" jndi-name="java:jboss/datasources/oracleDS" pool-name="java:jboss/datasources/oracleDS" use-ccm="false">
<connection-url>jdbc:oracle:thin:@ogo:1521:sioraprd</connection-url>
<driver-class>com.p6spy.engine.spy.P6SpyDriver</driver-class>
<driver>ojdbc6.jar</driver>
<security>
<user-name>bollm1</user-name>
<password>bollm1</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
<background-validation-millis>0</background-validation-millis>
</validation>
<statement>
<prepared-statement-cache-size>0</prepared-statement-cache-size>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>


Top
 Profile  
 
 Post subject: Re: Hibernate does not rollback super class entity tables
PostPosted: Tue Apr 24, 2012 2:46 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
I copied the p6spa.jar in to the JBOSS_HOME/standalone/lib directory. Also update the spy.properties. But no luck.


Can you please check, in which directories ojdbc6.jar is placed ?
The first thing I would do, is to copy p6spy.jar into all directories where there is also a ojdbc6.jar


Top
 Profile  
 
 Post subject: Re: Hibernate does not rollback super class entity tables
PostPosted: Tue Apr 24, 2012 11:54 am 
Newbie

Joined: Fri Apr 20, 2012 5:32 pm
Posts: 4
I copied the p6spy.jar into $JBOSS_HOME/standalone/deployments/
That where I found ojdbc6.jar too.


Top
 Profile  
 
 Post subject: Re: Hibernate does not rollback super class entity tables
PostPosted: Fri Jan 04, 2013 2:10 am 
Newbie

Joined: Fri Jan 04, 2013 2:04 am
Posts: 1
Hi,
I am having same problem. I have a unique constraint on derived table. Hibernate Save() method still inserts data parent table. I used session.currentTransaction.rollBack(). However this is deleting all the records which got created for that user session.
Can any one suggest a solution.

Thanks
Madhan


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.