-->
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: Getting Multi-valued Attributes in HQL select clause
PostPosted: Mon Aug 28, 2006 9:45 am 
Newbie

Joined: Wed May 24, 2006 9:30 am
Posts: 7
Hibernate version: 3.1.1

Hi All,

A little background

I am developing a query service based on HQL for my DataBase (DB Contains Identity Information). This service will be used for only data retrieval by many other systems. My DB structure is as follows

Entity A
Single valued Attributes : name, description, status
Multi valued attributes : alternate names, group codes

We represent above structure as following tables
Code:
Table A (PK - entity_id)
entity_id          name          description          status
1                    a1           d1                      s1

Table B (PK - entity_id, alternate_names)
entity_id          alternate_names
1                    an1
1                    an2

Table C (PK - entity_id, group_code, group_type)
entity_id          group_code          group_type
1                    gc1                      gt1
1                    gc2                      gt2


I am representing my tables in hibernate as per the tables only means
Entity A with attributes as entity_id, name, description, status, set entity B and set entity C
Entity B with attributes as entity_id, alternate_names (composite id calss will be there)
Entity C with attributes as entity_id, group_code, group_type (composite id calss will be there).

My problem

I want to retrieve data as follows this in one HQL
String entity_id, String name, List of (String alternate_names)
ex: 1, a1, List(an1, an2)

Currently I am writing following HQLs
select a.entity_id, a.name, b.alternate_name from A a, B b where a.entity_id=b.entity_id
or
select a.entity_id, a.name, elements(a.alternate_names) from A a

And I am getting the following result
1 a1 an1
1 a1 an2

Here 1 and a1 is repeating and i need to process the result to get 1, a1, list(an1, an2)

Please let me know how I can get
String entity_id, String name, List of (String alternate_names) from a hql or some hql related utility.

I am ready for any suggestions or help or Links. Code changing for me is not a issue as I am still in design phase. But I cannot change the DB.


Top
 Profile  
 
 Post subject: issue resolved
PostPosted: Wed Sep 06, 2006 7:27 am 
Newbie

Joined: Wed May 24, 2006 9:30 am
Posts: 7
check this
http://www.hibernate.org/393.html


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.