I have the below HQL Query (with postgres)
select up from UserPromotion up where up.user = :user and up.createTimestamp = (select max(u.createTimeStamp) from UserPromotion u where u.user = :user);
Unfortunately, when translated, the SQL query becomes,
select userpromot0_.id as id, userpromot0_.version as version, userpromot0_.credit as credit, userpromot0_.Promotion as Promotion, userpromot0_.user_info as user_info, userpromot0_.last_mod_by as last_mod6_, userpromot0_.last_mod_time as last_mod7_, userpromot0_.created_by as created_by, userpromot0_.create_time as create_t9_ from usr_promotion userpromot0_ where (userpromot0_.user_info=42324 )and (userpromot0_.create_time=(select userpromot1_.id from usr_promotion userpromot1_ where (userpromot1_.user_info=42324 )))
which returns multiple columns which then crashes my app. I have a work around with order by. But, i would like to use the max()
aggregate functionality.
Can you tell me if i am supposed to do something differently or is this a bug?
Thanks.
|