-->
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.  [ 3 posts ] 
Author Message
 Post subject: Unexpected AST node
PostPosted: Tue Feb 14, 2006 10:28 pm 
Beginner
Beginner

Joined: Wed Jan 25, 2006 7:32 am
Posts: 34
Hi,

Am using Hibernate with spring in POJO framework.

I tried to use dao to execute the following query:

dao.find(" select l , (select count(*) from Message m where m.listing_id=l.id) as Message_received from Listing l where l.subscriber_id='Jane '");

but it returned the following error:

===========================
[ERROR] PARSER - *** ERROR: <AST>:0:0: unexpected AST node: query
===========================

Am not sure what is the problem with this query statement in hibernate. But when I execute it using mysql common without hibernate, this query is able to return me the result as what I expect to see as below:

==================
ID Subscriber Message_received
==================
1 Jane 2
---------------------------------
3 Jane 2
---------------------------------
4 Jane 1
---------------------------------
8 Jane 0
===================
The select statement counts the number of Messages for each listing for Subscriber Jane.


For your information, there exists 2 table as below:

Listing
============
Id Subscriber
============
1 Jane
---------------------
2 Thong
-----------------
3 Jane
-----------------
4 Jane
-----------------
5 Thong
-----------------
6 David
-----------------
7 Jane
===========


Message
=======================
ID Message Listing_id
=======================
1 XXXXXXXX 1
-----------------------------------------
2 YYYYYY 1
-----------------------------------------
3 GJGKJHG 2
-----------------------------------------
4 JJJJJJJJJJ 3
-----------------------------------------
5 JJdfJJJJJJJ 4
----------------------------------------
6 JJJJJJJdfsdf 5
----------------------------------------
7 JJJJJJ 6
----------------------------------------
8 JJJJJJJJasdJJ 3
======================


Listing_id is a the foreign key. Each Listing can have many Messages.


Please guide. Thank you!


meileng


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 15, 2006 1:41 am 
Beginner
Beginner

Joined: Wed Jan 25, 2006 7:32 am
Posts: 34
Is anybody out there able to help? Having a select count statement nested in another select statement. Can this be applied in hibernate?

Please help. Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 15, 2006 9:19 pm 
Beginner
Beginner

Joined: Wed Jan 25, 2006 7:32 am
Posts: 34
Hi All,

Can anyone share with me can hibernate support nested select statement as above mentioned? Am a newbie to hibernate.

I desperately need an answer . Thanky you!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

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.