I'm having a weird problem. I have the following table structure...
Offer <-> Offer_Category <-> Category
...to set up a many to many association.
The map is defined like this...
HasManyToMany(x => x.Categories)
.WithTableName("OFFER_CATEGORY")
.WithParentKeyColumn("offer_id")
.WithChildKeyColumn("category_id")
.FetchType.Join();
The query is defined like this...
ICriteria criteria = Session.CreateCriteria(typeof(Offer),
"offer");
criteria.Add(ExpressionEx.Eq((Offer x) => x.OfferStatus,
offerStatusId));
criteria.SetMaxResults(numberOfResultsPerPage);
ICriteria categoryLinks = criteria.SetFetchMode("Categories",
FetchMode.Eager)
.CreateCriteria("Categories")
.Add
(NHibernate.Criterion.Restrictions.IdEq(categoryId));
return categoryLinks.List();
When I run this in a unit test against SQLite, I get a single query,
joined. When I run this in Dev, against SQL 2005, I get one query for
Offers, and 20 queries for Categories.
Any ideas on what I'm doing wrong?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---