在我的休眠程序中,我收到以下异常:
log4j:WARN 找不到记录器(org.hibernate.cfg.Environment)的附加程序。log4j:WARN 请正确初始化 log4j 系统。线程“主”org.hibernate.MappingException 中的异常:需要使用 AnnotationConfiguration 实例
我的 Hibernate.cfg.config 文件是
<?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.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">1234</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/mayank</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show-sql">true></property>
<property name="hbm2ddl.auto">update</property>
<mapping class="one.Student"/>
</session-factory>
</hibernate-configuration>
The Student file is
package one;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class Student
{
@Id
private Long id;
private int roll;
private String name;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public int getRoll() {
return roll;
}
public void setRoll(int roll) {
this.roll = roll;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Student(Long id, int roll, String name) {
super();
this.id = id;
this.roll = roll;
this.name = name;
}
public Student() {
// TODO Auto-generated constructor stub
}
}
异常是什么意思,我做错了什么?