嗨,我正在尝试运行我的休眠应用程序,但我遇到了休眠异常。
我的 hibernate.cfg.xml 文件是
<?xml version='1.0' encoding='UTF-8'?>
<session-factory>
<property name="hbm2ddl.auto">update</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect </property>
<property name="connection.url">jdbc:mysql://localhost:3306/test</property>
<property name="connection.username">root</property>
<property name="connection.password">mysql</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<!-- <mapping resource="config\\hibernate.hbm.xml"/ -->
<mapping resource="config\\employee.hbm.xml"/>>
</session-factory>
员工.hbm.xml
<?xml version='1.0' encoding='UTF-8'?>
<hibernate-mapping>
<class name = "com.javatpoint.mypackage.Employee" table = "emp_TPCH" discriminator-value="emp">
<id name = "id">
<generator class = "increment">
</generator>
</id>
<discriminator column="type" type= "string"></discriminator>
<property name ="Name"></property>
<subclass name = "com.javatpoint.mypackage.Regular_Employee" discriminator-value="reg_emp">
<property name = "salary"></property>
<property name = "bonus"></property>
</subclass>
<subclass name = "com.javatpoint.mypackage.Contract_Employee" discriminator-value = "con_emp">
<property name = "pay_Per_Hour"></property>
<property name = "contact_Duration"></property>
</subclass>
</class>
</hibernate-mapping>
Employee.java 是
package com.javatpoint.mpackage;
公共类员工{
private int id;
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getname() {
return name;
}
public void setname(String name) {
this.name = name;
}
}
Contract_Employee.java
包 com.javatpoint.mpackage;
公共类 Contract_Employee 扩展 Employee {
private float pay_Per_Hour;
private String contact_Duration;
public float getPay_Per_Hour() {
return pay_Per_Hour;
}
public void setPay_Per_Hour(float pay_Per_Hour) {
this.pay_Per_Hour = pay_Per_Hour;
}
public String getContact_Duration() {
return contact_Duration;
}
public void setContact_Duration(String contact_Duration) {
this.contact_Duration = contact_Duration;
}
}
普通的 Employee.js 是
package com.javatpoint.mpackage;
公共类Regular_Employee扩展员工{
private float salary;
private int bonus;
public float getSalary() {
return salary;
}
public void setSalary(float salary) {
this.salary = salary;
}
public int getBonus() {
return bonus;
}
public void setBonus(int bonus) {
this.bonus = bonus;
}
}
伙计们请帮助我摆脱这个例外。