Cheetah
unread,Feb 22, 2011, 1:08:34 PM2/22/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to nhusers
I have a domain model that contains some structures that in simplified
form looks roughly like this:
class Entity {
int Id { get; set; }
IDictionary<ControlledVocabulary,string> Metadata { get; set; }
// ...
}
class ControlledVocabulary {
int Id { get; set; }
string Name { get; set; }
//...
}
The Entity.Metadata property is mapped as a map using index-many-to-
many. Under the hood, there are three tables here, one for Entity,
one for ControlledVocabulary, and one for the Metadata collection.
I can do HQL queries like this: "from Entity e join e.Metadata m where
index(m) = :cv" to get all entities that have a value stored for a
particular ControlledVocabulary item.
However, what I need to do now is a left join constrained by the
metadata, which I would think would be expressed thus: "from Entity e
left join e.Metadata m with index(m) = :cv". However, when I do that,
I get:
NHibernate.Hql.Ast.ANTLR.InvalidWithClauseException: with-clause
expressions did not reference from-clause element to which the with-
clause was associated
Is there a way to work around this, or a better way to model this kind
of controlled vocabulary structure in the domain? The IDictionary/map
model fits the business model exactly: each Entity is allowed to have
zero or one values for each ControlledVocabulary item.
Is this just plain a bug in the with clause handling?