-->
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.  [ 2 posts ] 
Author Message
 Post subject: CheckNullability in Save
PostPosted: Fri Jun 09, 2006 3:13 am 
Newbie

Joined: Fri Jun 09, 2006 2:59 am
Posts: 1
Hello,

I want to call Save in the ctor of every persistent object in my application.

I want to make a businesslayer where nobody can "forget" a save and has not to think about the order of save calls. Also I want a stable GetHashcode() and Equal() Method. So I need the definitive id of the persistent object already on creationtime.

So I have two questions:

1. Because the method CheckNullability is called in Save I will get an exception when I use not-null="true". Why is the check made already in DoSave inside the method Save? Later on (in Flush) the check will be made again.

2. Are there more problems when I do call Save() in the ctor of my persistent objects?

Thank you for anwering my newbie questions.

NHibernate version: 1.0.2


Last edited by egustl on Fri Jun 09, 2006 3:28 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: CheckNullability in Save
PostPosted: Fri Jun 09, 2006 3:23 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
egustl wrote:
2. Are there more problems when I do call Save() in the ctor of my persistent objects?


Depending on the id generator type used, the call of "Save" might actually insert new record into database. This is the case when MS SQL identity generator is used, at least.

Gert

_________________
If a reply helps You, rate it!


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