-->
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.  [ 5 posts ] 
Author Message
 Post subject: "Shit in, shit out" Persistance
PostPosted: Thu Apr 01, 2004 3:34 pm 
Regular
Regular

Joined: Sat Oct 11, 2003 11:13 am
Posts: 69
This is not really a Hibernate question. But here are many experts about ORM, and I need your opinion.

We use a homegrown ORM. When an object is persisted, it is only persisted if its state is modified. It is not considered to be modified if it has initial values. So a newly created object instance (new MyBusinessObject()) is not persisted. The persistance layer does not persist it because it is not modified. Only if it is modified, for example with setName("Agent Smith"), it can be persisted.

For me it is very strange that this has nothing to do with validation. Its the persistance layer which doesn't persist such "virgin" objects. Its not our validation layer which prevents it. I think that this is a matter of validation, not a matter of persistance layer. On the other side, it seems strange to me, that an object must not be persisted just because none of its properties was modified after initalization. I would say: Shit in, shit out. But is it really "shit"?

I apologize that this is not a Hibernate question. I hope you can help me. Here are many experts for such topics.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 02, 2004 12:53 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Whether the object has to be updated is a persistance layer topic, but the persistance layer has to know that your object is brand new so it does not need "updates" and must be persisted.
Validation is a vetoe process, just on top of the ORM core.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 03, 2004 6:51 am 
Regular
Regular

Joined: Sat Oct 11, 2003 11:13 am
Posts: 69
emmanuel wrote:
Whether the object has to be updated is a persistance layer topic, but the persistance layer has to know that your object is brand new so it does not need "updates" and must be persisted.
Validation is a vetoe process, just on top of the ORM core.


I think you mean something else than I meant.

Lets take a transient (not yet persisted) Person instance which has a transient Address instance. The transient Address instance has not been touched with setting any attributes after it has been got with new Address(). It has initial values for street, city and so on, whatever the initial values may be.

Then I persist Person with cascading save. But in our ORM the Address is not persisted in the case above. It is only persisted if the dependend transient objects have been "modified" or "touched". Like if street is initially "default", it is required that setStreet("something") was executed. Then the transient Address is "modified" and then it is saved when Person is saved. Otherwise not.

I think Hibernate does not care. It saves Person and Address always if in the mapping file cascading save was set. But our ORM does not so.

I just try to figure out if I am wrong thinking that a ORM should persist "untouched" dependend transient (not yet persisted) objects (provided that the mapping file allowes cascading saves).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 05, 2004 3:45 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
quereinsteiger wrote:
I think you mean something else than I meant.

I got you perfectly, and I still think an ORM should persist untouched objects according to it's metadata.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 05, 2004 1:45 pm 
Regular
Regular

Joined: Sat Oct 11, 2003 11:13 am
Posts: 69
emmanuel wrote:
quereinsteiger wrote:
I think you mean something else than I meant.

I got you perfectly, and I still think an ORM should persist untouched objects according to it's metadata.


I didn't want to convince you of something else.

I'm happy to read that you are of the same opinion like me.

Thanks for answering my question.


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