-->
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.  [ 3 posts ] 
Author Message
 Post subject: Confusion with mutable attribute
PostPosted: Tue Sep 28, 2004 2:45 pm 
Beginner
Beginner

Joined: Mon Aug 09, 2004 3:35 pm
Posts: 22
Location: Minneapolis, MN, USA
In Hibernate 2.1.6 if you try to delete an entity with
mutable="false" set you get an exception. However, if you
try to update the same entity, you don't get an exception.
Instead, the entity is placed in the session cache so future
session.get()s return the "updated" value. The updated
values are *not* persisted.

This isn't a critical issue for my app, I just came across it while
writing a test case. Can someone explain this behavior?

thanks,

-r


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 28, 2004 9:15 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I think you misunderstand the intended semantics of update(). update() is a not an explicit instruction to perform a SQL update. It is an instruction to perform reassociation, with state that *might* be changed. For an immutable object, we can assume it is *not* changed.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 29, 2004 11:56 am 
Beginner
Beginner

Joined: Mon Aug 09, 2004 3:35 pm
Posts: 22
Location: Minneapolis, MN, USA
I may be confusing the intended semantics, but it's based on
what the docs say. The API doc for Session.update(Object, Serializable)
states: "Update the persistent state associated with the given
identifier...." It's different for Session.update(Object) which
states: "Update the persistent instance with the identifier of the
given transient instance....." Also, the reference doc states:
"Immutable classes, mutable="false", may not be updated or
deleted by the application."

I'm more or less ambivalent about the behavior. I can preclude
access to the update in my app. I'm just pointing out what seems to
be an inconsistency.

thanks,

-r

p.s. I would just fix the doc and submit a patch, if I was sure about
what to write.


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