Yep, that is the issue.  Refresh fixed it.  Thanks.

On Aug 18, 10:58 pm, Markus Zywitza <[email protected]> wrote:
> Just for the record:
>
> If you create A and B objects, do you do this in the way shown below?
>
> var a = new A();
> var b = new B();
> b.A = a;
> a.RelB.Add(b); // this one is necessary!!!!
>
> From what you write, I guess you omitted the last line. Then the already
> created A instance does not have the B instance added, since we are here in
> plain C# land.
> After you destroyed the first level session cache and created a new version,
> the instance is correctly created ny NH, something which wasn't done by the
> code beforehand.
> If you don't want to add it by hand, you have to refresh the A entity after
> creating the B childs.
>
> -Markus
>
> 2010/8/17 Dan Jasek <[email protected]>:
>
>
>
> > Yep.  I tried to add a flush.  No affect.
>
> > Originally I thought this is only for SubSelects, but it looks to be
> > true for all fetch strategies.
> > Even Join does not work.  The SQL query shows the join, but it doesn't
> > make it into the object.  When an SQL query is sent to standard out,
> > does it always query the database?  Or will it forgo the actual
> > database hit if it thinks the result is in the first level cache?  Or
> > will it ignore the row from the DB if it can find the object in the
> > cache?
>
> > I don't know much about the NH internals, but it looks like an issue
> > with a stale instance of A.  If I do a findall of B, it is correct and
> > the BelongsTo association to A is correctly setup.
>
> > The actual class I am using is a bit more complecated than the example
> > I described.  I will setup a simpler test to better nail down where
> > the issue is coming from.
>
> > -Dan
>
> > On Aug 17, 1:02 am, Markus Zywitza <[email protected]> wrote:
> >> Sorry, incomplete mail last time. I was playing with Thunderbird, but
> >> it doesn't work as expected....
>
> >>   Am 17.08.2010 00:05, schrieb Dan Jasek:> I have an AR class (lets call
>
> A) with a HasMany relationship where
>
>
>
> >> > Fetch is set to FetchEnum.SubSelect (called RelB).
> >> > I have a test which opens up a SessionScope, creates a number of A's,
> >> > then does a FindAll() for the class.  The returned objects have their
> >> > RelB set to null.
> >> > If I close the session, then call the FindAll, RelB has the expected
> >> > list.
>
> >> This is a flushing problem. Please try to add a
> >> SessionScope.Current.Flush(); before querying the objects.
>
> >> Did you configure AR to flush automatically? If yes, do you have the
> >> same behaviour without FetchEnum.SubSelect? In this case, NH seems to
> >> miss noticing that a query on A requires a flush if dirty Bs are in the
> >> session.
>
> >> -Markus
>
> > --
> > You received this message because you are subscribed to the Google Groups
>
> "Castle Project Users" group.> To post to this group, send email to 
> [email protected]
> .
> > To unsubscribe from this group, send email to
>
> [email protected]<castle-project-users%2bun­[email protected]>
> .> For more options, visit this group at
>
> http://groups.google.com/group/castle-project-users?hl=en.
>
>
>
> - Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" 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/castle-project-users?hl=en.

Reply via email to