gist JS

Wednesday, September 27, 2006

Hibernate cannot dereference scalar collection element

You're getting this because nobody told you about the secret little hibernate 'elements' and 'indices' functions. Yes I know there's 1001 tutorials/books/etc on how to creating a mapping file with lists or sets or maps. But no, no of course it wouldn't be usefull to put in said tutorials a small hint as to how one actually queries these collections.

from the hib docs:
from Player p where 3 > all elements(p.scores)
from Show show where 'fizard' in indices(show.acts)


Bill said...

yes, you are right: I can not find any document about it.
Could you please explain a litter more about how to use it?

jdwyah said...

Hibernate docs chapter 14.9.

"HQL functions that take collection-valued path expressions: size(), minelement(), maxelement(), minindex(), maxindex(), along with the special elements() and indices functions which may be quantified using some, all, exists, any, in."

It seems works like you might expect. Indices gives you you map keys and elements the values, then you pick the appropriate modifier from some, all, etc, and apply your condition. Do you have an example of what you're doing?

Anonymous said...

Thanks Jeff. Very usefull.
-- dara

Anonymous said...

Thanks for this hint. I found the solution here, not in Hibernate docs.

John Alert said...

Great step by step solution, thanks for the help!

Spring Hibernate Online Training | Hibernate Training in Chennai Java Training Institutes

Hibernate Online Training | Java Online Training | Java EE Online Training

Nandhini said...

Amazing blog about the various informative information on the programming languages.... Web Designing Training in Chennai