这是关于java hibernate的问题.
我hibernate.cfg.xml是
<?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/poc</property>
<property name="hibernate.connection.username">user</property>
<property name="hibernate.connection.password"/>
<mapping class="test.person" file="" jar="" package="" resource="person.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Run Code Online (Sandbox Code Playgroud)
与数据库的连接正常,我可以探索数据库和表,
我的样本
person.hbm.xml 是
<?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-mapping>
<class name="test.person" table="person">
<id name="id" type="int" column="id" >
<generator class="assigned"/>
</id>
<property name="fName">
<column name="fName" />
</property>
<property name="lName">
<column name="lName"/>
</property>
<property name="age">
<column name="age"/>
</property>
<property …Run Code Online (Sandbox Code Playgroud)