-->
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: Number is first char in column name leads to error (MSSQL)
PostPosted: Wed Apr 12, 2006 4:16 am 
Newbie

Joined: Wed Apr 12, 2006 4:10 am
Posts: 2
Hello,
I have to use an old and big database in my application and it is best if i don't change anything like column names and stuff.
Problem is, someone named a column "4_a_prinzip". Now if hibernate queries that table i get the following error:

Code:
Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Line 1: Incorrect syntax near '.4'.


in order to make it work the column name would have to be surrounded by []
ie
Code:
select * from foo where foo.[4_a_prinzip] = 1


is there a way to tell hibernate to do so?

thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 4:48 am 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
How did you map that column in the .hbm.xml files?

maybe if you do:
column="[4_a_prinzip]"


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 5:19 am 
Newbie

Joined: Wed Apr 12, 2006 4:10 am
Posts: 2
hmm i'm not using hibernate directly, but jboss ejb3. maybe better to ask there? :)


Top
 Profile  
 
 Post subject: Re: Number is first char in column name leads to error (MSSQ
PostPosted: Wed Apr 12, 2006 12:08 pm 
Beginner
Beginner

Joined: Tue Aug 26, 2003 2:46 pm
Posts: 45
Location: Saskatoon SK Canada
I understand you don't want to change the existing database objects, but can you create a view? If so, you could create a view that maps the table in question but changes the names of the offending columns. You could then use the view as the 'table' in your Hibernate code.

_________________
Maury


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.