Lets say I have two entities: Stable
, and Pony
.
Stable
has an IList<Pony>
with a HasMany
mapping configured with Cascade.All()
.
That means that if I do session.Save(myStable)
, each Pony
in the collection will be saved.
However, what happens if I do this?
Pony myLittlePony = new Pony(Color.Brown);
Stable myStable = new Stable(WoodTypes.RichMahogany);
myStable.Ponies.Add(myLittlePony);
session.Save(myStable);
session.Save(myLittlePony);
Will NHibernate try to save myLittlePony
twice? or is NHibernate "smart" enough to know that myLittlePony
has already been persisted to the DB?
Are there any performance implications from doing something like this?