The code fragment below describes what I want to do using criteria but it
blows up with the above error.
There is a 1 to many relationship between Buildings and AttributeValues and
my aim is to find all Buildings which have an AttributeValue of "Large" *and
* an AttributeValue of "Blue".
var attributeValueAlias1 = new AttributeValue();
var attributeValueAlias2 = new AttributeValue();
var result = repository
.CreateCriteriaFor<Buildings>()
.Join(o=>o.AttributeValues, ()=> attributeValueAlias1)
.Join(o=>o.AttributeValues, ()=> attributeValueAlias2)
.Add(() => attributeValueAlias1.Value == "Large")
.Add(() => attributeValueAlias2.Value == "Blue")
.List();
There are few posts on this forum and on other sites but none with a
solution to the problem which is described
here<http://stackoverflow.com/questions/5940922/duplicate-association-path-error-in-hibernate>
and
here<http://blog.dezfowler.com/2008/06/duplicate-association-path-bug-in.html>
I can make it so a test is added to see if the alias exists using
_criteria.GetCriteriaByAlias(alias) before adding it so the Duplicate alias
error does not occur but then there is only a single join and it results in
a SQL Where clause which will never be true
SELECT *
FROM Buildings this_
inner join AttributeValues attributev1_
on this_.Id = attributev1_.BuildingId
WHERE
attributev1_.Value = 'Large'
and attributev1_.Value = 'Blue'
It is not a complicated or unusual query so I'd be surprised if there isn't
a work around.
We are using NHibernate 2.1
Thanks in advance
Neil
Note: this question has also been posted to StackOverflow
here<http://stackoverflow.com/questions/7981027/nhibernate-queryexception-duplicate-association-path>
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/nhusers/-/a2psEeLMbHYJ.
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.