-->
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.  [ 4 posts ] 
Author Message
 Post subject: Error using array_agg() PSQL function
PostPosted: Mon Aug 02, 2010 2:59 pm 
Newbie

Joined: Mon Aug 02, 2010 2:51 pm
Posts: 1
Hi,

I'm trying to get a single string by concatenating a text field. Of course, the version of Postgres I'm using doesn't have the string_agg function, so I have to use array_agg:

Code:
String queryString = "select new PerformanceProfile(min(sp.id), sp.category, max(sp.samplecount), array_agg(sp.toptraces)) " +
              "from PerformanceProfile sp where sp.operation = '" + pageName + "' and " +
              "sp.keytype = 6 and sp.timewidth = 0 and sp.summarylevel = 0 and sp.category is not null group by sp.category " +
              "order by sp.category desc";
            list = getHibernateTemplate().find(queryString);


However, it throws an "Unable to locate appropriate constructor on class" error, presumably because I don't know the return type to use for array_agg, and I can't seem to find it in the documentation:

Code:
public PerformanceProfile(Integer id, String category, Integer samplecount, String toptraces) { ... }


Any help would be great, thanks.


Top
 Profile  
 
 Post subject: Re: Error using array_agg() PSQL function
PostPosted: Fri Aug 06, 2010 8:48 am 
Newbie

Joined: Fri Aug 06, 2010 8:43 am
Posts: 2
hey there,

ive got the same problem here...i cannot use array_agg, also tried to use custom functions, without any success.

did you solve this already? i would be very interested :)

thanks,
balazs


Top
 Profile  
 
 Post subject: Re: Error using array_agg() PSQL function
PostPosted: Fri Aug 06, 2010 11:22 am 
Newbie

Joined: Fri Aug 06, 2010 8:43 am
Posts: 2
i think i misunderstood your problem, and the previous post was about a different one, which i could solve anyways.

but now i also tried to use array_agg and with a constructor with a param Object. and the new problem is now that Hibernate wants to fetch a long value (i applied the function on table.id) and obviously the value returned after applying array_agg is not a long but a {l1,l2, ..., ln} list.

so i would like to ask you how can you fetch this list without an exception being thrown because of the long-list conversion?

thanks,
balázs


Top
 Profile  
 
 Post subject: Re: Error using array_agg() PSQL function
PostPosted: Thu Feb 27, 2014 4:21 am 
Newbie

Joined: Thu Feb 27, 2014 4:08 am
Posts: 3
Location: Frankfurt, Germany
I could make it work by changing the variable types in the constructor to Object and making a casting, like this_

public Hospital(Object hospitalId, Object hospitalName){

log.debug("Hospital Id: {}",hospitalId);
log.debug("HospitalName: {}",hospitalName);

this.hospitalId= hospitalId.toString();
this.hospitalName= hospitalName.toString();

}

But in the named query it´s all strings. I am migrating from EclipseLink to hibernate and everything was working fine with strings before :-(


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.