Search code examples
javaspringhibernatejdbcjndi

Detect Hibernate dialect from DataSource


A datasource resolved this way:

final JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
dsLookup.setResourceRef(true);

entityManagerFactoryBean.setDataSource(dsLookup.getDataSource("jdbc/translation"));
entityManagerFactoryBean.getJpaPropertyMap().
     put(Environment.DIALECT_RESOLVERS, StandardDialectResolver.class.getCanonicalName());

Will give me this exception:

Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set

Unfortunately i do not know what the concrete Database is.

How to let hibernate decide what dialect to use?


Solution

  • Works with Hibernate 4, not sure why they droped that feature.