Hi Iam unable to write a HQL for Temporary table in mysql. Here is my query SELECT outer21.user_id, outer22.user_game_status, outer21.user_game_start_time FROM (SELECT user_id, user_game_start_time FROM user_current_game_details_master u WHERE current_game_id = (SELECT MIN(current_game_id) FROM user_current_game_details_master u1 WHERE u.user_id = u1.user_id AND u.user_id='reddy' GROUP BY u.user_id)) outer21 JOIN (SELECT user_id, user_game_status FROM user_current_game_details_master u WHERE u.user_game_start_time = (SELECT MAX(user_game_start_time) FROM user_current_game_details_master WHERE day_id = (SELECT day_id FROM day_details WHERE day_date = CURDATE()))) outer22 ON outer21.user_id = outer22.user_id
When i converted this into HQL and try to run application getting following exception: Exception in thread "main" java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ( near line 1, column 77 [..... Here is my code StringBuffer outer21=new StringBuffer(); outer21.append("select u.userCurrentGameDetailsMasterPK.userId, u.userGameStartTime from UserCurrentGameDetailsMaster u "); outer21.append(" where u.userCurrentGameDetailsMasterPK.currentGameId=(" ); outer21.append(" select min(u1.userCurrentGameDetailsMasterPK.currentGameId) from UserCurrentGameDetailsMaster u1 "); outer21.append(" where u.userCurrentGameDetailsMasterPK.userId=u1.userCurrentGameDetailsMasterPK.userId and upper(u.userCurrentGameDetailsMasterPK.userId)=upper('reddy') "); outer21.append(" group by u.userCurrentGameDetailsMasterPK.userId)"); StringBuffer outer22=new StringBuffer("select u.userCurrentGameDetailsMasterPK.userId,u.userGameStatus from UserCurrentGameDetailsMaster u"); outer22.append(" where u.userGameStartTime = ("); outer22.append("select max(u1.userGameStartTime) from UserCurrentGameDetailsMaster u1"); outer22.append(" where dayId=("); outer22.append("select d.dayId from DayDetails d where dayDate=curdate()))"); StringBuffer outer2=new StringBuffer(); outer2.append("select outer21.userId,outer21.userGameStartTime,outer22.userGameStatus from ("); outer2.append(outer21); outer2.append(") outer21 join ("); outer2.append(outer22); outer2.append(") outer22 on outer21.userId=outer22.userId"); em.createQuery(outer2.toString());
Please help me in resolving this issue.
Thanks in advance
Thank you Chandra
|