[hibernate-dev] Regarding Implementation of getTables(Identifier catalog, Identifier schema) function in Hibernate

Ashudeep Sharma ashu00.speed at gmail.com
Tue Jul 4 04:15:57 EDT 2017


Hi Team,
            I was looking at the implementation of
*Code:*
public NameSpaceTablesInformation getTables(Identifier catalog, Identifier
schema)
and
*Code:*
public TableInformation getTable(Identifier catalog, Identifier schema,
Identifier tableName)
function and found a little bit of differences in the implementation part.
On looking at the comments, the way to go is:

// The table did not define an explicit namespace:
1) look in current namespace
2) look in default namespace
3) look in all namespaces - multiple hits is considered an error

I believe the same logic is also applied in getTables(Identifier catalog,
Identifier schema) function, except that the schemaFilter has been
initialized to "" instead of null.
Please refer to this piece of code
https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/tool/schema/extract/internal/InformationExtractorJdbcDatabaseMetaDataImpl.java#L320

I checked the parameter definition of ResultSet getTables(String catalog,
String schemaPattern, String tableNamePattern, String[] types) throws
SQLException
https://docs.oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.html#getTables(java.lang.String,
java.lang.String, java.lang.String, java.lang.String[])
, which says
schemaPattern - a schema name pattern; must match the schema name as it is
stored in the database; "" retrieves those without a schema; null means
that the schema name should not be used to narrow the search

since the code checks for the condition that database support schemas, i
think it should be initialized to null instead of "".

Let me know your thoughts.

Thanks,
Ashudeep


More information about the hibernate-dev mailing list