从Hibernate4到Hibernate5的建表
hibernate4的建表配置(最少配置)
<hibernate-configuration>
<session-factory >
<!--在hibernate.cfg.xml配置文件中-->
<!--配置本地方言 hibernate4与hibernate5配置的不同之处主要表现在这里-->
<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/tt?characterEncoding=utf8</property><property name="hibernate.connection.username">root</property><property name="hibernate.connection.password">root</property>
<!--是否在控制台显示语句--><property name="show_sql">true</property>
<!--映射实体类配置信息-->
<!-- 注解配置,映射类<mapping class="pojo.Student"/>
--><mapping resource="pojo/Student.hbm.xml"/>
</session-factory>
</hibernate-configuration>
hibernate5的配置(最少配置)
<hibernate-configuration>
<session-factory >
<!--在hibernate.cfg.xml配置文件中-->
<!--配置本地方言 hibernate5导入了自己的方言信息-->
<property name="dialect">org.hibernate.dialect.MySQL5Dialect</property><!--配置数据库连接信息--><property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property><property name="hibernate.connection.url">jdbc:mysql://localhost:3306/tt?characterEncoding=utf8</property><property name="hibernate.connection.username">root</property><property name="hibernate.connection.password">root</property>
<!--是否在控制台显示语句--><property name="show_sql">true</property>
<!--映射实体类配置信息-->
<!-- 注解配置,映射类<mapping class="pojo.Student"/>
--><mapping resource="pojo/Student.hbm.xml"/>
</session-factory>
</hibernate-configuration>
更多推荐
从Hibernate4到Hibernate5的建表
发布评论