hibernate.xml用来配置Hibernate的全局环境。
<property name="connection.url">jdbc:mysql://localhost:3306/ssmproperty>
<property name="connection.driver_class">com.mysql.cj.jdbc.Driverproperty>
<property name="connection.username">Cailinhaoproperty>
<property name="connection.password">CAIlinhao11014359property>
<property name="hibernate.c3p0.acquire_increment">10property>
<property name="c3p0.idle_test_period">10000property>
<property name="c3p0.timeout">5000property>
<property name="c3p0.max_size">30property>
<property name="c3p0.min_size">5property>
<property name="hibernate.c3p0.max_statements">10property>
<property name="show_sql">trueproperty>
<property name="format_sql">trueproperty>
<property name="dialect">org.hibernate.dialect.MySQL8Dialectproperty>
<property name="hibernate.hbm2ddl.auto">updateproperty>
<mapping resource="org/example/Entity/CustomerEntity.hbm.xml"/>
<mapping resource="org/example/Entity/OrdersEntity.hbm.xml"/>
<mapping resource="org/example/Entity/AccountCourseEntity.hbm.xml"/>
<mapping resource="org/example/Entity/AccountsEntity.hbm.xml"/>
<mapping resource="org/example/Entity/CoursesEntity.hbm.xml"/>
实体关系映射文件,用来将实体类和数据库表建立映射关系。
DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.example.Entity">
<class name="org.example.Entity.CustomerEntity" table="customer" schema="ssm">
<id name="id" column="id" type="java.lang.Integer">
<generator class="uuid"/>
id>
<property name="name" column="name" type="java.lang.String"/>
<property name="age" column="age" type="java.lang.Integer"/>
<set name="orders" table="orders" lazy="true" inverse="true" cascade="delete">
<key column="customer_id"/>
<one-to-many class="org.example.Entity.OrdersEntity"/>
set>
class>
hibernate-mapping>