-->
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.  [ 5 posts ] 
Author Message
 Post subject: Reserved word in hibernate query
PostPosted: Fri Oct 13, 2006 3:27 pm 
Newbie

Joined: Fri Oct 13, 2006 3:08 pm
Posts: 3
Hibernate version:
3

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
ORA-01747: invalid user.table.column, table.column, or column specification

Name and version of the database you are using:
Oracle 9i

The generated SQL (show_sql=true):
SELECT new tbook.mod.ResponseData(count(add), add, weight) FROM Nphcdata WHERE year = 2006 GROUP BY add, weight ORDER BY weight, add

Debug level Hibernate log excerpt:

15:14:25,329 WARN [JDBCExceptionReporter] SQL Error: 1747, SQLState: 42000
15:14:25,329 ERROR [JDBCExceptionReporter] ORA-01747: invalid user.table.column, table.column, or column specification

There is a column in my table called ADD. It looks like hibernate does not entertain this reserved word. I tried using single quotes but it does not work.

In Oracle sql, it works if ADD is in double quotes like
SELECT "ADD", WEIGHT FROM Nphcdata WHERE year = 2006 GROUP BY "ADD"

This does not work in HQL.

Please advise if there is any work around for this problem.

Thank You.
Himanshu


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 13, 2006 3:33 pm 
Regular
Regular

Joined: Tue Sep 26, 2006 11:37 am
Posts: 115
Location: Sacramento, CA
For mysql you can define the table in the mapping file as
Code:
table="`add`"


Try that and see if it works. Otherwise try something like the following or some other variation

Code:
table="\"add\""


Good luck!

Marius


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 13, 2006 4:05 pm 
Newbie

Joined: Fri Oct 13, 2006 3:08 pm
Posts: 3
Thanks for your reply Marius.

I had tried this but it didn't help.

I even tried in the mapping file,

<property name="add" type="java.lang.Long">
<column name='"ADD"' precision="10" scale="0" />
</property>

But no luck.

Thanks though...

- Himanshu


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 13, 2006 4:29 pm 
Newbie

Joined: Fri Oct 13, 2006 3:08 pm
Posts: 3
It worked with

<property name="add" type="java.lang.Long">
<column name='"ADD"' precision="10" scale="0" />
</property>


Put the reserved word in the double quotes and wrap it with single quote for the column name.

Thank You.
Himanshu


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 2:35 pm 
Regular
Regular

Joined: Tue Sep 26, 2006 11:37 am
Posts: 115
Location: Sacramento, CA
Thanks for sharing, will make a note of it :)

It seems I did send you on the proper path, if you agree please rate my posting. Thanks!

Marius


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