-->
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.  [ 2 posts ] 
Author Message
 Post subject: How to Write HQL for the native SQL
PostPosted: Sun Sep 09, 2007 12:40 am 
Newbie

Joined: Sun Sep 09, 2007 12:30 am
Posts: 1
Hi all,

I have a native SQL query written for SQL Server 2005.

The logic i want to get is :-
Quote:
i have 3 tables Account, Mailbox, Account_Mailbox. Every account has associated Mailboxes. I want to fetch those mailboxes that are excluding from the given account. I have an account_adminstrator_id (Every Account is created by an admin).

The native SQL for it is as below:-

Code:
<sql-query>
SELECT *
   FROM mailbox   
   WHERE mailbox.administrator_account_id=?    
   AND mailbox.mailbox_id NOT IN (   
                   SELECT mailbox.mailbox_id   
   FROM account, account_mailbox, mailbox
   WHERE account.address=?   
    AND account.account_id=account_mailbox.account_id   
    AND account_mailbox.mailbox_id = mailbox.mailbox_id   
   AND mailbox.administrator_account_id=?)
</sql-query>


when i execute this query i am getting the resultset of objects, but i want to retrun Mailbox object.

how can i change the sql query to query and to retrieve Mailbox Object. I am very much new to Hibernate.

My Hibernate Version is 3.1
DB SQLServer 2005


Thanks in advance
saikiran


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 11, 2007 9:10 am 
Newbie

Joined: Fri Sep 07, 2007 4:16 am
Posts: 16
use ResulTransformer api

rate me


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.