But neither of these are available without doing a connection.> No, what should it based the cache on ?
Firstly I think just simple properties: databaseName & databaseMajorVersion be suitable…
Or simply just do the detection outside SF and set the dialect.
If useJdbcMetadata and databaseName == null & databaseMajorVersion == null
Then get connection and initialize as it is. So it call getConnection only once – but this is SettingsFactory – not suitable solution…
It seems like a “if ( useJdbcMetadata ) {” block – not a right place in SettingsFactory -> buildSettings, seems should be parameters for buildSettings function - databaseName, databaseMajorVersion. databaseName, databaseMajorVersion – should be initialized from other place.
Then only do that when you know the configuration is to be used with reverse engineering and thrown away again.
Just setAttribute("hibernate.temp.use_jdbc_metadata_defaults", true) or autoConfigureDialect (better if not a job of hibernate core) could be a nice feature,
again, hibernate core should not care about this and it should definitely not created separate threads.
It prevent user to make one more configuration step to setup dialect by hands…
It’ a pity if not possible to use “hibernate.temp.use_jdbc_metadata_defaults” or autoConfigureDialect …
May be the solution is to get databaseName & databaseMajorVersion or in general dialect in independent thread – only synchronization issue,
There really arent much magic to this - just check if the dialect is set, if not try and detect it based on jdbc url, driver class name, dtp connection etc. and only if that fails you will have to ask for it.
So Hibernate Console Config could display it’s nodes and in case when the user try to expand “Database” (here is a try to connect to db in any case) - db dialect could get its value. But in case if db dialect doesn’t get value – the user should specify this by hands… Look like too much “could” and “but”, but this is only specific cases – in general it seems useful and possible to use (autoConfigureDialect in independent thread). In the bad case we just get a long running thread.