-->
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: Issue with Inheritance.Joined Strategy
PostPosted: Mon Jan 20, 2014 4:35 am 
Newbie

Joined: Mon Jan 20, 2014 2:33 am
Posts: 1
Hi,

I have two classes A and B, A is the parent Class and B is extending A. In my DAO class, I am trying to persist B i.e. session.save(objB). Internally Hibernate is firing two insert statements i.e. one for A and another for B. So My issue is :
I am passing one of the variable in B object as NULL, where database will not allow to insert into B table.
When i am persisting the Same Object i.e. session.save(objContainingNULLB).

When i do session.flush, Hibernate is inserting into A successfully and throwing exception at insert into B Table (saying Cannot insert null).
I am doing session.clear() in catch block, It is not removing the successful insert object i.e. A.

And after all inserts, i am having transaction.commit() i.e. I am following Single Transaction mechanism i.e. for multiple insert only one transaction i am using. Before For loop, i am starting the transaction and after For loop, I am committing the transaction.

So the value is inserting successfully into A without inserting into B.

Can you please tell, how can i avoid this situation. Whether Hibernate will not rollback internally?


Thanks in advance,
Vishal


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.