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.  [ 10 posts ] 
Author Message
 Post subject: createSQLQuery Question
PostPosted: Tue Apr 25, 2006 2:47 am 
Newbie

Joined: Thu Oct 06, 2005 8:08 pm
Posts: 19
Code:
// Trying code from Hibernate 3.1 docs (section 10.4.4)
List cats = session.createSQLQuery(
    "SELECT {cat.*} FROM CAT {cat} WHERE ROWNUM<10",
    "cat",
    Cat.class
).list();


This doesn't compile. createSQLQuery takes only one string and there are no overloads. The JavaDoc (http://www.hibernate.org/hib_docs/v3/api/) agrees with the compiler. After some digging, this looks like code from Hibernate 2. The documentation must be out of date.

How do I do this in Hibernate 3?

Java 1.5.0_06
Hibernate 3.1.2


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 25, 2006 6:30 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
I came over the same issue some time ago...

You can do your Query like that:

String sql = "select c.* from CAT c where ROWNUM < 10";

SQLQuery sqlQuery = session.createSQLQuery(sql);
sqlQuery.addEntity(Cat.class);
List cats = sqlQuery.list();

_________________
Please don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 25, 2006 10:04 am 
Newbie

Joined: Thu Oct 06, 2005 8:08 pm
Posts: 19
Thanks Mike! It works.

So, I'm not crazy; the documentation is out of date. How does everyone figure out how to use this software then?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 25, 2006 1:09 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the documentation is not out of date, it is just documenting a deprecated method (which all are moved to org.hibernate.classic.Session).

read the migration guide.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 25, 2006 4:20 pm 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
Max, maybe this should be mentioned in the documentation. I would say that 90% of the readers think that this is the way to do native SQL in "standard" (an not classic) Hibernate 3.

_________________
Please don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 25, 2006 5:04 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hibernate 3.2 sql docs are very much updated - let me know if you find issues there.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 25, 2006 6:59 pm 
Newbie

Joined: Thu Oct 06, 2005 8:08 pm
Posts: 19
max wrote:
the documentation is not out of date, it is just documenting a deprecated method (which all are moved to org.hibernate.classic.Session).

read the migration guide.


I agree that the documentation is documenting a deprecated method and that the actual API has been moved to org.hibernate.classic.Session.

However, this is the current version of the documentation for the most recent production version of Hibernate and that documentation section is in no way labeled as "classic" or "deprecated" or "obsolete" at all.

So, yes, the documentation most definitely IS out of date, Max.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 26, 2006 2:58 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
so provide a patch if it is important for you ;)

The migration guide specificly mentions the classic interface.

The docs in svn is uptodate - I would like to receive bugreports to that since it is basically a rewrite.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 26, 2006 1:00 pm 
Newbie

Joined: Thu Oct 06, 2005 8:08 pm
Posts: 19
max wrote:
so provide a patch if it is important for you ;)

The migration guide specificly mentions the classic interface.

The docs in svn is uptodate - I would like to receive bugreports to that since it is basically a rewrite.


I'm not migrating old code to a newer version of Hibernate so why would I look at a migration guide? I'm trying to write new code for the most recent 3.1.3 production version from scratch. So I've been looking in the current 3.1.x documentation on the website.

I completely believe you that the new 3.2 docs are up-to-date. However, I'd rather not use pre-release software (to avoid issues such as this one). Maybe the 3.2 docs are better for 3.1.3 work? Where can I see them? I can't find them on the site at "http://www.hibernate.org/5.html".

My issue is resolved, however the docs should be fixed so that other users don't have to go through the same thing. How do I go about submitting a documentation patch?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 27, 2006 4:51 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
documentation patches are gladly accepted against the 3.2 because that is where new releases will come from.

The docs are available by downloading the release or go look in SVN.

_________________
Max
Don't forget to rate


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