-->
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: Can all aliases/columns be quoted?
PostPosted: Wed Jul 21, 2004 7:24 am 
Newbie

Joined: Mon Jul 19, 2004 12:57 pm
Posts: 8
Location: UK
Hi,

I am trying to run the Hibernate unit tests with Informix. Here is one problem I have come across. Informix changes all column and alias names to lowercase.

In the connection string you can specify one of two modes depending on the DELIMIDENT parameter:
- Allow quoted identifiers for column names etc. This is necessary to pass various Hibernate tests as quoted identifiers are used a lot. In this case the JDBC driver does not do any mapping in the ResultSet.findColumn, so you can only find columns if you refer to them with lowercase names.
- Do not allow quoted identifiers. In this case when you request a column by name from a ResultSet, the JDBC driver changes it to lowercase before passing it on to Informix, which means that ResultSet retrievals of columns by name will work fine. But you can't use quoted identifiers, which means lots of Hibernate tests would fail.

For instance, with DELIMIDENT=1 set to allow quoted identifiers:

select foo as FooBar from bar;

You will get:
- ResultSet.findColumn("foobar") succeeds
- ResultSet.findColumn("FooBar") fails
- So the unit tests fail (specifically ParentChildTest can't find column nullBlob0_)

select foo as "FooBar" from bar;

You will get:
- ResultSet.findColumn("foobar") fails
- ResultSet.findColumn("FooBar") succeeds
- Unit test would now succeed

So my question is: is there a way to tell Hibernate to use quotes around all references to columns/aliases? Could this be controlled by the dialect? Is there a better solution (I'd rather not hack the JDBC driver).

Versions:
Hibernate 2.1.4
Informix 9.4 UC2 on RedHat
JDBC 2.21JC5
JRockit 1.4.2_04

Thanks,

Marko


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 21, 2004 9:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
As per documentation, quote things with backticks in the mapping file.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 21, 2004 9:20 am 
Newbie

Joined: Mon Jul 19, 2004 12:57 pm
Posts: 8
Location: UK
But this is a unit test that ships with Hibernate---I assume I shouldn't need to change the test in order to get it to pass, and I also assume it works correctly with other databases already.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 22, 2004 11:26 am 
Newbie

Joined: Mon Jul 19, 2004 12:57 pm
Posts: 8
Location: UK
After digging deeper I found that I could fix the problems with Informix by specifying:

Configuration.setNamingStrategy(ImprovedNamingStrategy.INSTANCE);

This gets rid of the mixed-case column names.

I understand that this is intended to be a per-project setting. However the default is currently hardcoded. Given the database dependecy here, wouldn't it be better if the default came from the dialect, or at least the hibernate.properties?


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.