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"