-->
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: A 'non-feature' or 'bug' in Hibernate when saving data??
PostPosted: Thu Mar 03, 2005 8:03 pm 
Newbie

Joined: Fri Jan 28, 2005 8:58 am
Posts: 9
Hi,

I have a wierd problem when saving data in a specific scenario. Since this can potentially cause havoc, I am hoping someone can provide a solution.

I have 3 objects.

ObjectA is mapped in Hibernate using .hbm file
ObjectB is a member of ObjectA and does not need to be stored.
ObjectC is a member of ObjectB and is mapped in Hibernate using .hbm file

In the program, I do this.

Session session = sessionFactory.openSession();

// Change the state of ObjectA
// Change the state of ObjectC

Transaction t = session.beginTransaction();
session.save(ObjectA);
t.commit();

Now, even though ObjectB does not have any mapping in Hibernate, the Session still keeps track of changes to ObjectC (which is inside ObjectB) and saves it when I try to save ObjectA, although I want to save only ObjectA and not ObjectC.

While I understand that ObjectC is reachable from ObjectA, what I don't understand is how it can save it when ObjectB, which is sitting in the middle has no explicit database mapping.

I tried making ObjectB transient, and it did not work. Since ObjectB has no Hibernate mapping, I cannot say "cascade="none"" also.

Is there any workaround for this problem?


Sathya.


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.