慕标1714062
2016-06-23 22:53
cfg.xml配置文件
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql:///hibernate?useUnicode=true&characterEncoding=UTF-8</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="hbm2ddl.auto">create</property>
<mapping resource="Students.hbm.xml"/>
students.hbm.xml文件
<class name="com.hibernate.Students" table="STUDENTS">
<id name="id" type="int">
<column name="ID" />
<generator class="assigned" />
</id>
<property name="name" type="java.lang.String">
<column name="NAME" />
</property>
<property name="sex" type="java.lang.String">
<column name="SEX" />
</property>
<property name="birthdat" type="java.util.Date">
<column name="BIRTHDAT" />
</property>
<property name="address" type="java.lang.String">
<column name="ADDRESS" />
</property>
来人帮忙看看原因
试试添加包路径,即<mappng resource="com.hibernate.Students.hbm.xml"/> 注意与你的类名包名相一致。
Hibernate初探之单表映射
74810 学习 · 793 问题
相似问题