-->
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.  [ 6 posts ] 
Author Message
 Post subject: Zugriff auf zu Grunde liegende SQL Anfrage einer Query ?
PostPosted: Tue Feb 21, 2006 10:32 am 
Newbie

Joined: Tue Feb 21, 2006 10:23 am
Posts: 6
Hallo Hibernater,

wenn ich eine Hibernate Query Instanz habe, wie kann ich dann auf den SQL Code zugreifen, der ausgeführt würde, wenn ich z.B die list() methode auf der Query aufrufe ?

Vielen Dank im voraus,
Dirk


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 22, 2006 5:01 am 
Beginner
Beginner

Joined: Wed Aug 04, 2004 4:33 am
Posts: 45
Location: Switzerland
Meinst Du im Code?

Für das Log kannst Du shwo_sql=true setzen in der Konfiguration.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 22, 2006 9:18 am 
Newbie

Joined: Tue Feb 21, 2006 10:23 am
Posts: 6
ja im Code, um das SQL z.B als subselect in ein anderes SQL einzubinden.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 22, 2006 1:01 pm 
Beginner
Beginner

Joined: Tue Jul 19, 2005 5:08 am
Posts: 26
Location: Germany
und wieso nimmst du nicht das zugrunde liegende HQL statement für dein subselect?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 02, 2006 5:09 am 
Beginner
Beginner

Joined: Mon Nov 22, 2004 11:21 am
Posts: 42
Probier mal folgenden Code:

Code:
    Query query = getSession().getNamedQuery("findPartner");
    QueryTranslator trans = new QueryTranslatorImpl("findPartner"
        , query.getQueryString()
        , new HashMap()
        , (SessionFactoryImplementor) getSessionFactory());
    trans.compile(new HashMap(), false);
    String sqlString = trans.getSQLString();

Den musst Du natürlich anpassen falls Du Parameter verwendest, etc.
Viele Grüße,
Georg

_________________
Real programmers confuse Halloween and Christmas because OCT 31 = DEC 25


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 07, 2006 8:34 am 
Newbie

Joined: Tue Mar 07, 2006 8:31 am
Posts: 7
<hibernate-configuration>
<session-factory>
...
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
...
</session-factory>
</hibernate-configuration>


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