-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Criteria that restrict a map attribute, is that possible?
PostPosted: Wed Aug 30, 2006 10:44 am 
Newbie

Joined: Tue Jan 10, 2006 9:22 am
Posts: 6
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?

_________________
Best regards
Dirceu Semighini Filho


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.