Few questions about nhibernate & fluent nhibernate?

You would have better luck getting all of your questions answered if you broke them up into separate questions, but I'll address a couple of your questions anyway.

You would have better luck getting all of your questions answered if you broke them up into separate questions, but I'll address a couple of your questions anyway: Automapping, Custom Conventions, and Overrides If one of your business requirements is that most properties should not be nullable then you should make that the default by providing your own convention to the automapper. Take a look at this blog post for how you can do this. Then if you have a mapping that needs to differ slightly from your conventions, then you can provide an automapping override by implementing IAutoMappingOverride where in you only specify the columns/ids/relationships that are aberrant to the conventions.

The documentation at the FluentNbernate wiki on Overrides and Conventions is actually quite good, I highly recommend reading it. Readonly Entities If I was doing this, what I'd do is have an N internal set property called something like IsReadonly { get; internal set; }, when an object is retrieved from somewhere that it should be read-only, then set that property before returning it to the caller. If you have an explicit Save method on a repository, you can check that property and not do the actual Nbernate save if it's true.

If you rely on the Nbernate dirty checking for saving on session Flush then you could implement an Nbernate listener which would not save the entity if that property was true. Identifiers One word (acronym) GUID; hi-lo can work, but it can get complicated and a bit finicky. For Nbernate to properly track the object it has to have a unique ID.

If you're using auto ids then Nbernate will go to the database to get an ID when you Save your entity and before you do the Flush. Comb GUIDs solve the problems that you'll run into with auto ids and hi-lo in exchange for taking a little bit more space in your DB, and memory. When using FluentN if your entity has a GUID as the type of it's Id property, it will automatically use the Guid Comb strategy.

Also what happens if say it goes on Save to check for an id yet you don't do a commit it for an extended period of time. Say for some reason you put the thread to sleep for 5 minutes and in the meantime something else has saved and commit. Won't there be somehow a conflict now since I would think they both would have the same id's.

– chobo2 Sep 12 at 21:08 @chobo2 Yes I feel that all Primary Keys should use GUIDs. Since no two, even when temporal or spatially separated, GUID generators will ever generate colliding IDs, the clients themselves can create IDs without talking to the server. I'm not sure how something else would save and commit your entity while you slept, but if it did happen that's exactly what optimistic concurrency is all about, read up on it in conjunction with N – joshperry Sep 12 at 22:04 with the readonly thing I am sort of doing that.

Instead I am putting them through session.Readonly() but the problem with your soultion and the one I got is if you get a collection back you got to loop through each one and make it readonly. I also don't get what you mean by "explicit save". Are you saying that if I am say I got a commit and since now that entity has changed it will commit those changes even though they should be readonly?

– chobo2 Sep 14 at 17:13.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions