index() function in with clause

26 views
Skip to first unread message

Cheetah

unread,
Feb 22, 2011, 1:08:34 PM2/22/11
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?

rj

unread,
Jan 21, 2014, 11:18:02 AM1/21/14
to nhu...@googlegroups.com
Seems this is still a problem. I too have the same issue now. Do you have any workaround for this bug?

Matthew Gabeler-Lee

unread,
Jan 21, 2014, 1:28:36 PM1/21/14
to nhu...@googlegroups.com
I'm sure I found a way around my problem, but I don't remember what it was, and I'm not working for that company any more so I don't have access to the code to go find out the answer, sorry :(



--
You received this message because you are subscribed to a topic in the Google Groups "nhusers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nhusers/lPUbkMv2Q-s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nhusers+u...@googlegroups.com.
To post to this group, send email to nhu...@googlegroups.com.
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages