Hi,
I want to do a merge of a transient object which some of its properties are
assigned with detached objects, in order to get a persistent object with all
its properties assigned with persistent instances (using cascade="merge").
Is this the correct usage scenario for merge?
Here is a sample entity:
public interface INum
{
int Num { get; }
}
public class Cat : Entity, INum
{
private State state;
protected Cat() { }
public Cat(State state)
{
this.state = state;
}
public State State { get { return state; } } <--- mapped using
access="field.camelcase"
public int Num {
get { return state.Num; }
set { state.Num = value; }
}
}
The problem that I'm facing is that Merge is trying to read the Num property
from a Cat created using the protected constructor (the persistent
instance?) before assigning its "state" field, thus throwing a
NullReferenceException in the getter.
A simple solution would be to add a check to verify that state != null in
the getter, but that would be only to support NH functionality and it would
have nothing to do with my domain.
Do I need to add the check for state != null?
Can NH be improve to handle this situation?
Regards.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---