Java 从数据源检测Hibernate方言

Java 从数据源检测Hibernate方言,java,spring,hibernate,jdbc,jndi,Java,Spring,Hibernate,Jdbc,Jndi,数据源的解析方式如下: final JndiDataSourceLookup dsLookup = new JndiDataSourceLookup(); dsLookup.setResourceRef(true); entityManagerFactoryBean.setDataSource(dsLookup.getDataSource("jdbc/translation")); entityManagerFactoryBean.getJpaPropertyMap(). put(E

数据源的解析方式如下:

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

entityManagerFactoryBean.setDataSource(dsLookup.getDataSource("jdbc/translation"));
entityManagerFactoryBean.getJpaPropertyMap().
     put(Environment.DIALECT_RESOLVERS, StandardDialectResolver.class.getCanonicalName());
我会给我一个例外:

Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
不幸的是,我不知道具体的数据库是什么


如何让hibernate决定使用哪种方言?

适用于hibernate 4,但不确定他们为什么放弃该功能。

您需要明确设置hibernate方言。。。。。根据datasource的某些属性。看起来,我认为这应该是导致错误的原因。从错误中,我猜它需要“方言”属性,这应该由程序员手动设置。你不觉得吗?如果我当时想错了,请告诉我。Thanks@Pater伤害我。。!!我以为您在开始连接数据库时遇到了问题。