-->
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.  [ 3 posts ] 
Author Message
 Post subject: Native query cannot be executed
PostPosted: Thu Feb 02, 2006 2:34 pm 
Newbie

Joined: Tue Oct 25, 2005 10:49 pm
Posts: 9
Hi there,

using Hibernate 3.0 and struts.

I have one HQL query and Native SQL query, HQL one works properly, but the native one cannot be executed.


Any input is appreciated.

Fei
HQL one
Code:
         Query query = session
               .createQuery("select * from Customer");



Native one

Code:
Query query = session
               .createSQLQuery("select * from customer")
               .addEntity("customer",Customer.class);


Error:

DEBUG http-80-Processor25 org.hibernate.util.JDBCExceptionReporter - could not execute query [select * from customer]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 02, 2006 10:51 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
That form of addEntity replaces all instances of {customer} with the table name taken from the Customer mapping. Either change your SQL query to
Code:
select {customer.*} from customer
or change your addEntity to addEntity(Customer.class).


Top
 Profile  
 
 Post subject: yes, it works now
PostPosted: Fri Feb 03, 2006 12:15 am 
Newbie

Joined: Tue Oct 25, 2005 10:49 pm
Posts: 9
thank you, tenwit

it works


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