-->
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: HQL query returning improper type
PostPosted: Wed May 19, 2010 12:17 pm 
Newbie

Joined: Fri May 07, 2010 4:31 pm
Posts: 3
I am writing a simple query in hibernate. It is not returning the proper information. So my code looks like this:
Code:
List<Object> skulist = session.createSQLQuery("select sku from (select ppbd.prft_sku as sku, avg(coalesce(ppbd.prft_net_margin_percent)) as net_margin_avg from analytics.projection_by_day ppbd where ppbd.prft_sku like :sku_like group by ppbd.prft_sku) tbl1 where tbl1.net_margin_avg >= :margin_percent")
               .setString("sku_like", "546%")
               .setDouble("margin_percent", new Double(0.39))
               .list();


This produces the following SQL select sku from (select ppbd.prft_sku as sku, avg(coalesce(ppbd.prft_net_margin_percent)) as net_margin_avg from analytics.profit_projection_by_day ppbd where ppbd.prft_sku like ? group by ppbd.prft_sku) tbl1 where tbl1.net_margin_avg >= ?. When I run this against my database it returns the correct data. When I run the query through Hibernate, the prft_sku field returns as a Character and not a String. This is really confusing because if I use the Query method, session.createCriteria(ProfitProjectionByDayDAO.class).list(), then the sku comes back as a string. Unfortunately I have not been able to find any way of running my query with this method. Any ideas what would cause this issue or if you have any tips on getting that query to run with the second method? Thanks,

Dwain


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.