Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.0
Mapping documents:
<class
name="Order"
table="order_table">
<id
name="id"
access="field">
<generator
class="assigned" />
</id>
<!-- some atributes-->
<map
name="supplAttrs"
outer-join="true"
table="order_suppl_attr">
<key
column="order_id" />
<map-key
type="string"
column="name"
length="50" />
<element
type="string"
column="value"
length="500" />
</class>
.
.
.
<class
name="DeliveryUnit"
table="delivery_unit">
<id
name="id"
access="field">
<generator
class="native" />
</id>
<!-- some atributes-->
<many-to-one
name="order"
not-null="true">
<column
name="order_id"
unique-key="key_du" />
</many-to-one>
Name and version of the database you are using:
SQLServer 2000
I would like to select an Delivery unit and make some restrictions to order attributes (this I can do now), including some restrictions to the supplAttrs.
I can't do this adding restrictions to the supplAttrs in my criteria.
orderQuery.add(
Restrictions.eq( "supplAttrs[name]", "reference" ) ).add(
Restrictions.ilike( "supplAttrs[value]", QueryUtils.likeExpr(
_orderReference.getText() ) ) );
where orderQuery is a Criteria created in a deliveryUnit criteria
Criteria<?> orderQuery = duQuery.createCriteria( "order" );
and duQuery is a deliveryUnit query.
I have a named query that restricts order by its supplAttrs in this way:
select ord.id
from Order ord
where ord.supplAttrs[ :name ] like :value
order by ord.id
But when I put this in the criteria I have got an exception
br.com.neolog.persistence.PersistenceException: org.hibernate.QueryException: could not resolve property: supplAttrs[reference] of className
even If I put something like this:
orderQuery.add(
Restrictions.eq( "supplAttrs.name", "reference" ) )
it doesn't work.
I have tried to put an Restriction.sqlRestriction to do it by hand, but all the sqlRestricions enter in after the were clause of my sql.
I have tried many ways of solving this problem but I can't find a solution to this.
Someone here know how to solve this?