-->
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: SQLServer/Hibernate:Incorrect syntax near the keyword 'PLAN'
PostPosted: Sun Jun 20, 2010 3:09 am 
Newbie

Joined: Fri Jun 11, 2010 5:53 am
Posts: 4
Hi,

I'm facing below problem when using Hibernate with SQL server database. We have an existing application in oracle and we are extending the application database to include the SQL server compatibility as well. One of the tables is named as PLAN. Since PLAN is a key word in SQL server, am getting below error.

Schema Name : CODES
Table Name : PLAN

11:56:43,624 INFO [STDOUT] Hibernate: select this_.PLAN_CODE as PLAN1_8_0_, this_.PLAN_DESC as PLAN2_8_0_, this_.ACTIVE as ACTIVE8_0_ from CODES.PLAN this_
java.sql.SQLException: Incorrect syntax near the keyword 'PLAN'.

If its an inline query then i could sorround the table name with [] and make it work. But since its a hibernate call am not sure how to resolve this. The problem is i cant change the table name as its already in production with oracle. I need to resolve this asap.

Any help is highly appreaciated...

- Halel


Top
 Profile  
 
 Post subject: Re: SQLServer/Hibernate:Incorrect syntax near the keyword 'PLAN'
PostPosted: Sun Jun 20, 2010 6:52 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
In your mapping/annotation declaration, put backticks around the table name: <class table="`PLAN`" ..>. Hibernate should automatically convert the backticks to something that works in your database.


Top
 Profile  
 
 Post subject: Re: SQLServer/Hibernate:Incorrect syntax near the keyword 'PLAN'
PostPosted: Mon Jun 21, 2010 7:17 am 
Newbie

Joined: Fri Jun 11, 2010 5:53 am
Posts: 4
Thanks nordborg ! it worked :-)


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.