Sorry I meant to say I'm getting the backref error as well.

....SubClipsBackref

I've since split subclip into episidesubclip and clipsubclip with both
coming off a base class which have a collection of what we call
negativesubclips.
Now I'm getting the same error for them two collections. One of them
can exist but not both of them together. I have this mapping in
clipsubclip.hbm.xml and in episode.hbm.xml.

<bag name="NegativeSubClips" table="NegativeSubClip" order-
by="sequence" cascade="all-delete-orphan">
            <key column="SubClipID" not-null="true"></key>
            <one-to-many class="AVMS.Domain.Entities.NegativeSubClip" /
>
        </bag>

Do I have to split into separate classes and .hbms again. What is the
correct way to handle this?

On Dec 28, 1:50 pm, Davec <[email protected]> wrote:
> Hi guys,
> I'm getting the not-null property reference a null or transient value
> error as mentioned 
> here:http://stackoverflow.com/questions/568029/nhibernate-not-null-propert...
>
> Problem is the relationship causing the problem is unidirectional. The
> parents add child elements in via parent.acollection.add(child), there
> is no mapping going back the other way, so I never do child.parent =
> parent.
> Most of the solutions I've read on the web, relate to inverse = true,
> explicity setting the parent on the child before adding to the parent
> collection, not-null = true/false etc. none of these things worked for
> me. I wracked my head on it for a good long time.
>
> Sine I had another entity inserting correctly in the same level, and
> the only difference was that I was including an entity twice in two
> different parent collections, I decided to create a separate business
> object to see if that would work and hey presto it did.
>
> I'm posting this as much to seek clarification and also to log it
> incase it helps anyone else.
>
> Basically I'm trying to persist an unsaved graph. Within the graph I
> had two objects called, clip and episode.
> Both of these objects/mappings had a collection made up of Subclip
> entity. The mapping for clip was:
>
> <bag name="SubClips" table="SubClips" order-by="sequence" cascade="all-
> delete-orphan">
>             <key column="ClipID" not-null="true"></key>
>             <one-to-many class="AVMS.Domain.Entities.SubClip" />
> </bag>
>
> and the mapping for episode was
>
> <bag name="SubClips" table="SubClips" order-by="sequence" cascade="all-
> delete-orphan">
>             <key column="EpisodeID" not-null="true"></key>
>             <one-to-many class="AVMS.Domain.Entities.SubClip" />
> </bag>
>
> You'll see  that I use the same table, subclips to store both all
> instances of subclips. That table has two FK columns which both can be
> null, but logicially they noth should not be null at the same time.
> The cols are ClipID and EpisodeID. I put them into one DB to save
> effort. I put the not-null=true on the mapping anyway to force NH to
> update on the parent side, as the children don't know/care who their
> parent is.
>
> The two collections are cusions of each other. The episode class is
> the overall parent. It has a direct collection of Subclips (2nd one
> above) but one of its children (a clip) has the other Subclips
> collection (1st one above). I've found that even if I remove the
> mapping to clip (and hence subclip collection) I still get the backref
> problem, but when I remove the clip-> subclip collection itself from
> clip.hbml.xml NH runs fine. So it seems to be a mapping thing in
> general as opposed to a usage thing, because I wasn't actually using
> the clip object anywhere, but it only worked after commenting it out.
>
> When I specified the key column as both clipid or episideid it worked
> fine. Obviously the collection was persisted incorrectly with the
> wrong FK but we know why that was.
>
> I'm not sure if anyone has come across this before, it is possible for
> me to have two or more entities which have collections made up of the
> same type (and extracted from the same DB table). Obviously from a DB
> design point of few a row shouldn't have a load of nulls for possible
> parents but rather one parentid col. Nh sure does make tracking
> problems done difficult.
>
> Your thoughts are appreciated.
>
> cheers.

-- 
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.

Reply via email to