-->
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.  [ 3 posts ] 
Author Message
 Post subject: Does HQL/JPAQL provide a string aggregate function?
PostPosted: Thu May 26, 2011 6:02 pm 
Newbie

Joined: Sat Jun 30, 2007 7:45 am
Posts: 7
Location: India
Hi Hibernate/JPA gurus,

I am struggling to find a way using which I can get concatenate the values of a particular column from multiple rows as one comma separated String. If anyone can tell me a solution to it, it will give me a hell lot of a relief because it has become an obstacle for me.

I am using Entity Beans (3.0) with a hibernate 3 dialect and underlying DB is MySQL.

Example:

if my table has a column name with values

machine_id os_name
1 Mac
1 Windows
1 DOS
2 Mac
2 Windows

then I want the value returned by my JPA query as

1 'Mac,Windows,DOS'
2 'Mac,Windows'

I don't want to use native SQL. I have been searching for it since many days but couldn't locate it in any of the hibernate forum topics. Please let me know if any other information is required to make my problem clear to you.

Thanks a lot in advance.


Top
 Profile  
 
 Post subject: Re: Does HQL/JPAQL provide a string aggregate function?
PostPosted: Wed Jul 24, 2013 11:19 am 
Newbie

Joined: Wed Jul 24, 2013 11:17 am
Posts: 1
Did you found any solution for this problem?


Top
 Profile  
 
 Post subject: Re: Does HQL/JPAQL provide a string aggregate function?
PostPosted: Tue Jul 30, 2013 8:20 am 
Beginner
Beginner

Joined: Wed Feb 06, 2013 2:43 am
Posts: 46
There was no standard solution i was able to get for this.

But you can easiily achieve this using SQL queries :
Example :
SELECT machine_id
GROUP_CONCAT(machine_iD SEPARATOR ', ') AS ProductList
FROM Categories c
GROUP BY machine_iD

_________________
Thanks,
Ajit Singh
ajits@mindfiresolutions.com
www.mindfiresolutions.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.