Hibernate version: 3.1.2
Pseudo Mapping documents:
Code:
<class name="NE">
<property name="name"/>
... other properties ...
</class>
<class name="NetObj">
<property name="name" not-null="true"/>
<many-to-one name="ne" class="NE" not-null="true"/>
... other properties ...
</class>
I am attempting to run a Criteria query over NetObj where I would like the results
returned ordered by the name property of the related NE class.
From the reference manual:
Code:
List results = session.createCriteria(Domestic.class, "cat")
.createAlias("kittens", "kit")
.setProjection( Projections.projectionList()
.add( Projections.property("cat.name"), "catName" )
.add( Projections.property("kit.name"), "kitName" )
)
.addOrder( Order.asc("catName") )
.addOrder( Order.asc("kitName") )
.list();
When I try this code from the manual, I keep getting errors - the referenced property is unknown.
Basically I'm doing the equivalent of:
Code:
List results = session.createCriteria(NetObj.class)
.setProjection( Projections.projectionList()
.add( Projections.property("ne.name"))
)
.addOrder( Order.asc("ne.name") )
.list();
or
List results = session.createCriteria(NetObj.class)
.setProjection( Projections.projectionList()
.add( Projections.property("ne"))
)
.addOrder( Order.asc("ne.name") )
.list();
or
List results = session.createCriteria(NetObj.class)
.addOrder( Order.asc("ne.name") )
.list();
I get the same exception in both cases. Tracing into the Hibernate code,
it seems that H is not attempting to follow a path through the "ne" reference. Also, this happens whether or not I use the aliased version
for the specified entities (NetObj and NE).
Any help here would be greatly appreciated.