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 <dan...@jasek.org>:
> 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 <markus.zywi...@gmail.com> 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 castle-project-users@googlegroups.com
.
> To unsubscribe from this group, send email to
castle-project-users+unsubscr...@googlegroups.com<castle-project-users%2bunsubscr...@googlegroups.com>
.
> For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to castle-project-us...@googlegroups.com.
To unsubscribe from this group, send email to 
castle-project-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

Reply via email to