Hibernate - 无法创建会话工厂对象

时间:2017-11-01 11:02:32

标签: java hibernate

我正在尝试用Lynda课程学习Hibernate。我在尝试第一次应用HelloWorld时遇到了麻烦。我收到有关会话工厂对象的错误。

这是我的HelloWorldExample

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate           
Configuration DTD 3.0//EN" 
"http://hibernate.sourceforge.net/hibernate-   configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect   </property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver   </property>
<property     name="hibernate.connection.url">    jdbc:mysql://localhost:3306/messagerepository?     zeroDateTimeBehavior=convertToNull
</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">admin</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.query.factory_class">org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory</property>
<mapping resource="helloworldexample/Message.hbm.xml"/>

这是我的hibernate.cfg.xml

package helloworldexample;

public class Message  implements java.io.Serializable {


 private Short id;
 private String message;

public Message() {
}

public Message(String message) {
   this.message = message;
}

public Short getId() {
    return this.id;
}

public void setId(Short id) {
    this.id = id;
}
public String getMessage() {
    return this.message;
}

public void setMessage(String message) {
    this.message = message;
}
}

这是我的Message.java

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD     3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- Generated Jan 9, 2017 10:28:21 AM by Hibernate Tools 4.3.1 -->
<hibernate-mapping>
<class name="helloworldexample.Message" table="message"     catalog="messagerepository" optimistic-lock="version">
    <id name="id" type="java.lang.Short">
        <column name="id" />
        <generator class="identity" />
    </id>
    <property name="message" type="string">
        <column name="message" length="50" />
    </property>
</class>
</hibernate-mapping>

这是我的Message.hbm.xml

C:\Program Files\dotnet\dotnet.exe" pack src/Acp.Framework.Essentials

有没有人有任何想法?

干杯

0 个答案:

没有答案