is there a way to get the mapping at runtime and change it ?

for example you would have a method in your repository like
"LoadMyEntity(int Id; bool FetchManyToMany): MyEntity; "

in this method, if FechtManyToMany is true, then:

- Get internal nhibernate relationship mapping  for class MyEntity
- Set relationship lazy property to false
- Load object
- Set relationship lazy property to true

If is possible, it is a workaround

2009/4/1 Bartosz Pierzchlewicz <[email protected]>

>
> Thanks for response,
> I'am searching for more efficent solution.
> In such situation (<many-to-any>) we have one query for mapping table,
> and one for each element in collecion?
> I even think to do this in multiquery, but we need access to metadata
> (id and class). Do you know how to do it with current wersion?
>
> Another solution is to point NH to make join with specified tables,
> but as you told it is imposible without modification od NH.
>
> --
> Bartosz Pierzchlewicz
>
>
>
> On 31 Mar, 14:52, Fabio Maulo <[email protected]> wrote:
> > Not possible using <any> or <many-to-any> because NH need to load the 2
> > field before know which is the table to hit.
> >
> > 2009/3/31 Bartosz Pierzchlewicz <[email protected]>
> >
> >
> >
> >
> >
> >
> >
> > > Hi,
> > > my mapping:
> >
> > > <bag name="RelatedElements" access="property"
> > > table="RelatedElementsToCategory" lazy="true">
> > >      <key column="elemId" />
> > >      <many-to-any id-type="Int32" meta-type="System.String">
> > >        <meta-value value="Product" class="DataLibrary.DbProduct,
> > > DataLibrary" />
> > >        <meta-value value="Category"
> > > class="DataLibrary.SimpleDictionaries.DbRelatedCategory, DataLibrary" /
> >
> > >        <column name="elemType" />
> > >        <column name="RelElemId" />
> > >      </many-to-any>
> > >    </bag>
> >
> > > I spend several hours trying to eager fetch RelatedElements
> > > collection.
> > > I tried both HQL and Criteria API. Still without result.
> > > I also tried to do this using multiquery, but RelatedElements didn't
> > > contains 'id' and 'class' fields (mentionen in
> >
> > >http://groups.google.com/group/nhusers/browse_thread/thread/f5ebef1e6.
> ..
> > > ).
> >
> > > Did anyone tried to do this?
> >
> > > I'am using NHibernate 2.1.0.1001 (January 2009)
> >
> > --
> > Fabio Maulo
> >
>


-- 
Paulo R. Quicoli

Editor Técnico - ClubeDelphi Magazine - DevMedia

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