-->
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: Error found in Hibernate documentation!
PostPosted: Tue Apr 06, 2004 6:38 pm 
Beginner
Beginner

Joined: Tue Apr 06, 2004 6:13 pm
Posts: 39
Location: Pune, Maharashtra, INDIA
Hi,

It seems I have found an error in Hibernate documentation.

Pls review...

First and foremost I am newbie in the Hibernate word (3 months old) so I could be wrong (but my code works)

I wanted to restrict the results returned by my Hibernate class.

So wrote a static method, employing "Criteria Queries"

As per documentation http://www.hibernate.org/hib_docs/reference/pdf/hibernate_reference.pdf, "8.3.6 Criteria Queries" shud be used as :

Quote:
List cats = session.createSQLQuery("SELECT {cat.*} FROM CAT AS {cat} WHERE ROWNUM<10","cat",Cat.class).list();


But I found that the AS clause in the 'FROM <tablename> {<alias>}' part gives an exception (SQL Not properly ended)

It works fine without the AS clause

Of course I am working with an Oracle 9i database. (WinXP os, with WSAD)

my WORKING code:
Code:
public static List fetchOfflinePartnersWithProducts() throws PersistenceException {
      List partnerList = null;
      try {
         Session session = HibernateSession.currentSession();
         partnerList = session.createSQLQuery(
                  "SELECT {p.*} FROM PARTNER {p} WHERE p.partner_id IN " //further code removed for clarity      
                  "p", Partner.class).list();
         
      } catch (HibernateException e) {
         throw new PersistenceException(e);
      } catch (PersistenceException e) {
         throw new PersistenceException(e);
      }
     
      return partnerList;
    }


Any comments ?

_________________
thks
G1


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 06, 2004 6:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Agree its a doco problem. The text needs to be correct SQL for your target database. Its best if the AS in this case was removed.

Christian will have a look at this i'm sure.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 06, 2004 6:56 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Fixed.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: does not seem so
PostPosted: Wed Apr 07, 2004 9:30 am 
Beginner
Beginner

Joined: Tue Apr 06, 2004 6:13 pm
Posts: 39
Location: Pune, Maharashtra, INDIA
Fixed?????

It does not seems so.

I checked
http://www.hibernate.org/hib_docs/reference/html_single/#manipulating-data-s6b
and http://www.hibernate.org/hib_docs/reference/pdf/hibernate_reference.pdf

Or am I pulling the doc from my browser cache (I did refresh however)

_________________
thks
G1


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2004 9:30 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
In CVS.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2004 9:51 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I'm 98% certain that ANSI SQL allows TABLE AS ALIAS syntax. This is just an Oracle wrinkle.


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.