刚从官网下了hibernate4.3.4,结果照着官网doc中的示例class,xml写报了两个错误,实在是头疼
本帖最后由 u010344410 于 2014-03-24 15:36:10 编辑
[yabao=][/yabao]
实体类:
package cn.edu.jmu.hibernate.model;
public class Student {
private int id;
private String name;
private int age;
public int getAge() {
return age;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public void setAge(int age) {
this.age = age;
}
public void setId(int id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
}
配置文件:hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration SYSTEM "http://hibernate.sourceforge.net/hibernate-configuration-3.0dtd" PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/hibernate</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<!-- JDBC connection pool (use the built-in) -->
<!-- <property name="connection.pool_size">1</property>-->
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>
<!-- Enable Hibernate's automatic session context management -->
<!-- <property name="current_session_context_class">thread</property> -->
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<!-- <property name="hbm2ddl.auto">update</property> 自动生成建表语句-->
<mapping resource="cn/edu/jmu/hibernate/model/Student.hbm.xml"/>
<mapping class="cn.edu.jmu.hibernate.model.Student"/>
</session-factory>
</hiber