-->
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.  [ 4 posts ] 
Author Message
 Post subject: exception while executing HQL statement
PostPosted: Fri Apr 27, 2007 9:07 am 
Newbie

Joined: Fri Apr 27, 2007 8:17 am
Posts: 2
Hi,

I am getting exception while executing the following HQL statement.
The exception is , 'substr is not recongnised function' in the query.though i have used substring method. I am using jTDS driver for SqlServer 2005.


The query is ,
"select substring(ltrim(usr_first_name),1,1) from ep_usr ".

Hibernate version: hibernate3
Name of the database : SqlServer 2005.


Please provide a solution for this.

Thanks,
Ravikumar Raju V.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 27, 2007 9:25 am 
Regular
Regular

Joined: Mon Jun 12, 2006 5:33 am
Posts: 63
Hi vrkraju,
what is the whole function call? Is it a createQuery?
For native SQL, also consider using formula in the mapping files.

_________________
chucky

Don't forget to rate if this helps
-----------------------------------


Top
 Profile  
 
 Post subject: exception while executing native SQL statement in hibernate
PostPosted: Tue May 01, 2007 4:06 am 
Newbie

Joined: Fri Apr 27, 2007 8:17 am
Posts: 2
Hi,

I am using createQuery function. The whole query is

session.createQuery("select upper(substring(ltrim(usr_First_Name),1,1)) from usr");

The same query should be worked in both Oracle and SqlServer database.
Pls tell me what are the changes to be done.

For SqlSever i am using , jTDS dirver.
For Oracle it is, ojdbc14 driver.

Thanks,
Ravi.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 02, 2007 6:53 am 
Regular
Regular

Joined: Mon Jun 12, 2006 5:33 am
Posts: 63
Hi vrkraju,
1/ - when using the createQuery function, you must provide a HQL as argument and NOT native SQL. So your query is class and object oriented.

2/ - in you query :
Code:
select upper(substring(ltrim(usr_First_Name),1,1)) from usr

it seams that you have a class called usr (lowercase.... Strange for a java class) and a property called usr_First_Name. If this is the case try this:

Code:
select upper(substring(ltrim(u.usr_First_Name),1,1)) from usr u

If not, replace the corresponding mappings for usr (use the class name) and for usr_First_Name (use the property name).

Hope this helps

_________________
chucky

Don't forget to rate if this helps
-----------------------------------


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