Not a good news, but thanks for the answer. I guess maybe I'll use the
same workaround as you did.

It's not just eager-loading that's broken, but setting up the mapping
with Fluent NHibernate is a big hack, too.

On 25 juin, 15:16, webpaul <[email protected]> wrote:
> I have run into this problem as well when using anything other than a
> single primary key. I ended up just adding an identity column and
> using that as the key for the tables I had this problem with so if
> there is another solution I'd love to hear it.
>
> On Jun 24, 2:06 pm, jods <[email protected]> wrote:
>
>
>
> > Hello,
>
> > I have a mapping where the class T1 has a composite id, which contains
> > a reference to the class T2.
>
> > This works all fine, I can load both classes, same them, and so on.
>
> > My issue is performance-related. I would like to eager-load the T2
> > reference, but I absolutely can't manage to do it.
>
> > 1st try: use the Criteria API with .SetFetchMode("ReferenceToT2",
> > FetchMode.Eager).
> > No luck. The query executes without error, but the reference is an
> > uninitialized proxy. SQL profiler clearly shows that the query does
> > indeed not contain T2 at all. Just "select * from T1".
>
> > 2nd try: using HQL. "from T1 obj inner join fetch
> > obj.ReferenceToT2..."
> > Exactly the same result as 1.
>
> > 3rd try: changing the mappign: <key-many-to-one lazy="false" />
> > It works, in the sense that my reference is loaded when a query
> > returns. But looking at the profiler, it is not loaded with a join,
> > rather with a second select. One can consider that at least the
> > lazy="false" attribute was correctly honored, even if not in a
> > performant way.
>
> > The problem becomes worst when, in some cases, in need to fetch a 2nd
> > reference from T1. Any variation on the theme of
> > .CreateAlias("ReferenceToT2", "ref").SetFetchMode
> > ("ref.OtherReference", FetchMode.Eager)
> > simply doesn't work, even with eager-loaded T2 (using 3rd solution).
>
> > Is this a known limitation, a bug, am I missing something?
>
> > I would consider that not fulfilling the requested query without
> > returning an error is a bug...
>
> > Thanks for your help!- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -
--~--~---------~--~----~------------~-------~--~----~
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