从Hibernate4到Hibernate5的建表

编程入门 行业动态 更新时间:2024-10-22 10:37:18

从Hibernate4到Hibernate5的建表

从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的建表

本文发布于:2023-07-01 05:34:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/971438.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!