-->
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.  [ 2 posts ] 
Author Message
 Post subject: Dashes in table names and columns
PostPosted: Tue Apr 01, 2008 3:58 pm 
Newbie

Joined: Tue Apr 01, 2008 3:52 pm
Posts: 5
I am trying to use Hibernate with a Progress 10.1 database. This database has been around for many years and many of the table names and column names have dashes in them.

I am trying to see if I can configure Hibernate to allow for this.

For example, one table name is part-file. So if I wanted to extract a record from this table, the SQL would be:

select * from pub."part-file" where partno = 'some part number'

So the table name has to be surrounded with double quotes because of the dash in the table name.

Can Hibernate be configured to take this into consideration? Otherwise it looks like I get table/view not found SQL exceptions when it attempts to extract data from a table with a dash in the name.

I have this as my hbm.xml file:
Code:
<class name="objects.PartFile" table="pub.part-file">
         <id name="partno" >
            <generator class="native"/>
        </id>
       
        <property name="spc3" />
       
    </class>


But it won't of course let me put quotes in that table attribute ( unless I can somehow escape them.

Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 01, 2008 4:09 pm 
Newbie

Joined: Tue Apr 01, 2008 3:52 pm
Posts: 5
I actually was able to get this to work by using single quotes to wrap the attribute, then double quotes around the table name and or columns names.

Example for table name with dashes:


Code:
<class name="objects.PartFile" table='pub."part-file"'>


Example for column name with dashes:

Code:
<property name="quantityOnHand" column='"QTY-O-H"'></property>


This seems to work quite well.

Does anyone see anything wrong with this workaround or fix?


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