Saturday, May 17, 2008

Hibernate cannot dereference scalar collection element

Hibernate cannot dereference scalar collection element or how to query property that is of Set type of mapped class with hibernate.

My problem seemed simple. I had following class:

class Subordinate {
String id;
Set superiors;
}

This class was mapped with two tables. All I needed is to get all subordinates of superior with some id. When reading documentation it turn out to be easy if my set of superiors was not set of simple types. And I have spent some time on this until I found exact answer on this blog: http://jdwyah.blogspot.com/2006/09/hibernate-cannot-dereference-scalar.html

No comments: