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

andrea boriero andrea at hibernate.org
Tue Jul 4 04:57:15 EDT 2017


I think your consideration makes sense.

Trying to remember the reasons driving my choice to use the empty String
instead of null for the getTables method, but at the moment nothing that
pops us in my mind prevents the use of null.




On 4 July 2017 at 09:15, Ashudeep Sharma <ashu00.speed at gmail.com> wrote:

> 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
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>


More information about the hibernate-dev mailing list