-->
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.  [ 2 posts ] 
Author Message
 Post subject: HQL Syntax for association Map
PostPosted: Tue May 16, 2006 2:46 am 
Newbie

Joined: Tue May 16, 2006 2:23 am
Posts: 1
Location: Singapore
Hi,

I have a POJO Object like below

Class User {

String firstName;
String LastName;
Map properties;
}

The properties attributes is associated in hibernate mapping as below

<map name="properties"
table="User_Properties"
lazy="false"
inverse="false"
cascade="none"
sort="unsorted">
<cache usage="nonstrict-read-write" />

<key>
<column name="PARENT_FK" unique-key="UNIQUEXTS"/>
</key>
<index type="string" column="PROPERTYNAME"/>
<element type="com.db.caaa.domain.GenericProperty">
<column name="PROPERTYVALUE" not-null="false" unique-key="UNIQUEXTS"/>
</element>
</map>

User_properties table has 3 columns parent_fk foreign key to User table and propertyname and propertyvalue.

I want to search for a user with a specific property value. So my HQL is of this type below

Query q = "from User u where u.properties.propertyName ='City' and u.properties.propertyValue ='Singapore'

This query is un-successful. Can anyone help me how to form HQL for the above requirement.

Many thanks in advance

Cheers
Amarnath


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 17, 2006 3:06 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
There is a slightly different syntax for that, it should be something like this:

Query q = "from User u join u.properties p
where p.propertyName ='City' and p.propertyValue ='Singapore' "

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


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

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.