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: IQueryTranslator
PostPosted: Tue Feb 12, 2008 6:28 am 
Newbie

Joined: Tue Feb 12, 2008 6:17 am
Posts: 1
Hello,

I am trying to manually use the IQueryTranslator to translate a simple HQL to SQL.


Code:
            string hql = "from " + typeof(T).Name;

            IQueryTranslator translator = translatorFactory.CreateQueryTranslator(hql, new Hashtable(), _mySessionFactoryImplementor);

            translator.Compile(new Hashtable(), true);

            string sql = translator.SQLString;


The mapping xml

Code:
   <class name="Item" table="Items">
      <id name="ItemId" type="Guid">
         <generator class="guid"/>
      </id>
   </class>


The was expecting something like "select * from Items"
Instead the string returned is "select item0_.ItemId as x0_0_ from Items item0_"

Is this normal or am I doing something wrong here?
In the same class when I use

Code:
CreateQuery("from " + typeof(T).Name);


all is working fine, so the mapping shouldnt be the problem.


Any help is much apprecheated.

Cheers,
Michael


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 12, 2008 1:47 pm 
Regular
Regular

Joined: Tue Dec 25, 2007 3:41 pm
Posts: 57
Location: Argentina
Hi,

What's the difference between this query

Code:
select * from Items

And this:
Code:
select item0_.ItemId as x0_0_ from Items item0_


There is no difference. The translated query is the way that NH do it.

_________________
Dario Quintana


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.