Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Hibernate:没有设置方言。设置hibernate.dialogue属性_Java_Hibernate - Fatal编程技术网

Java Hibernate:没有设置方言。设置hibernate.dialogue属性

Java Hibernate:没有设置方言。设置hibernate.dialogue属性,java,hibernate,Java,Hibernate,我有以下hibernate.cfg.xml: <hibernate-configuration> <session-factory> <property name="hibernate.format_sql">true</property> <property name="hibernate.show_sql">true</property> <property name="h

我有以下
hibernate.cfg.xml

<hibernate-configuration>
   <session-factory>
      <property name="hibernate.format_sql">true</property>
      <property name="hibernate.show_sql">true</property>
      <property name="hibernate.connection.url">jdbc:mysql://localhost/EJB</property>
      <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
      <property name="hibernate.connection.username">root</property>
      <property name="hibernate.connection.password">password</property>
      <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
      <property name="hibernate.hbm2ddl.auto">update</property>
      <property name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property>
 <!-- Snip -->
然后,我在其他地方尝试了以下方法:

SimpleSelect pkSelect = new SimpleSelect(Dialect.getDialect());
这将导致以下异常:

org.hibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect.
请注意,以下是日志摘录:

02:26:48,714  INFO Configuration:1426 - configuring from resource: /hibernate.cfg.xml
02:26:48,717  INFO Configuration:1403 - Configuration resource: /hibernate.cfg.xml
02:26:48,909 DEBUG Configuration:1387 - hibernate.dialect=org.hibernate.dialect.MySQLDialect

你知道我做错了什么吗?

GetDialante()的javadoc说:

获取当前系统属性指定的方言的实例

因此,必须在
hibernate.properties
中配置
hibernate.dialogue
,此方法才能工作


使用
SessionFactoryImplementor#getdialante()

谢谢,但这并不是真正的问题。正在读取配置文件,并初始化方言,如日志中所示。(我已经用表明文件已被读取的日志更新了问题)
02:26:48,714  INFO Configuration:1426 - configuring from resource: /hibernate.cfg.xml
02:26:48,717  INFO Configuration:1403 - Configuration resource: /hibernate.cfg.xml
02:26:48,909 DEBUG Configuration:1387 - hibernate.dialect=org.hibernate.dialect.MySQLDialect