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