-->
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: Hi Iam unable to write a HQL for Temporary table in mysql
PostPosted: Wed Jul 08, 2009 9:29 am 
Newbie

Joined: Wed Jul 08, 2009 9:06 am
Posts: 2
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


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.