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: Hibernate (3.0 alpha) doesn't check for storesLowerCaseIdent
PostPosted: Wed Sep 01, 2004 3:20 am 
Newbie

Joined: Wed Sep 01, 2004 3:06 am
Posts: 9
When running Hibernate 3.0alpha against Postgresql 7.4.5, I noticed it tries to recreate all tables on every restart (which I enabled and is basically what I want).

The problem is, that PostgreSQL stores identifiers by default in lowercase. And while Hibernate has a check for uppercase identifiers it doesn't check for lowercase.

I saw this code in DatabaseMetadata.java (lines 52 through 62) in the getTableMetadata-method:
Code:
               if ( meta.storesUpperCaseIdentifiers() ) {
                  rs = meta.getTables(
                        StringHelper.toUpperCase(catalog),
                        StringHelper.toUpperCase(schema),
                        StringHelper.toUpperCase(name),
                        TYPES
                  );
               }
               else {
                  rs = meta.getTables(catalog, schema, name, TYPES);
               }


And there should be a second if to test for meta.storesLowerCaseIdentifiers() combined with lowercasing the identifiers and perhaps even a last check for meta.storesMixedCaseIdentifiers() instead of the else.

The above code should perhaps also be adjusted to distinguish between quoted identifiers and unquoted ones, since most databases that have non-mixedcase nonquoted identifiers will have mixedcase quoted identifiers and therefore different namings for the two.

Actually, why don't you use the Dialect to give back the correct identifier-name? It can easily get quite difficult if you try to toy around with things like: schema."Catalog".tablename."Column"


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 01, 2004 4:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
ok, i added stuff to handle the lowercase case.... in cvs ...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 01, 2004 5:33 am 
Newbie

Joined: Wed Sep 01, 2004 3:06 am
Posts: 9
There's no toLowerCase in StringHelper, so your code doesn't compile due to that issue. In my local checkout I added a similar method to toUpperCase in StringHelper:
Code:
    public static String toLowerCase(String str) {
        return str==null ? null : str.toLowerCase();
    }


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 01, 2004 5:41 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
oops, i forgot to check in a file.


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.