还是以区县和街道为例:
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.connection.driver_class">com.mysql.cj.jdbc.Driver</property>
<property name="hibernate.connection.username">root</property> <!-- 账户 -->
<property name="hibernate.connection.password">xxxx</property> <!-- 密码 -->
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernate?serverTimezone=GMT%2B8</property>
<!--加载的是什么数据库-->
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property> <!-- 打印sql语句 -->
<property name="hibernate.hbm2ddl.auto">update</property> <!-- 自动建表 -->
<!--<mapping resource="mapper/User.hbm.xml"></mapping> <!– 加载实体类的Mysq