先加载hibernate.properties,后加载hibernate.cfg.xml
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/spring_hibernate_1</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">bjpowernode</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.current_session_context_class">thread</property>
<!--
<property name="hibernate.current_session_context_class">jta</property>
-->
<mapping resource="com/bjpowernode/usermgr/domain/User.hbm.xml"/>
<mapping resource="com/bjpowernode/usermgr/domain/Log.hbm.xml"/>
</session-factory>
</hibernate-configuration>
============================
hibernate.hbm2ddl.auto
它包含4个属性:
create : 会根据你的model类来生成表,但是每次运行都会删除上一次的表,重新生成表,哪怕2次没有任何改变
create-drop : 根据model类生成表,但是sessionFactory一关闭,表就自动删除
update : 最常用的属性,也根据model类生成表,即使表结构改变了,表中的行仍然存在,不会删除以前的行
validate : 只会和数据库中的表进行比较,不会创建新表,但是会插入新值
==================================
本地事务
<property name="hibernate.current_session_context_class">thread</property>
JTA事务
<!--
<property name="hibernate.current_session_context_class">jta</property>
-->
分享到:
相关推荐
hibernate基本配置要用到的包,hibernate基本配置要用到的包
hibernate基本配置及使用方法,高手免看.
最基本的Hibernate的配置。亲测可以运行。 包含各种jar包,有配置说明。简单好用,你值得拥有
NULL 博文链接:https://qinglonghai.iteye.com/blog/569286
Hibernate3.x简单配置示例,单表简单映射及Hibernate基本配置示例
给大家带来了hibernate4基本配置方式,非常不错,具有参考借鉴价值,需要的额朋友参考下吧
帮助大家在配置hibernate方面提供支持
Hibernate教程01_Hibernate的HelloWorld及基本配置 http://blog.csdn.net/e421083458/article/details/8794127 该源码为Hibernate教程配套源码
好了,下面列出在MyEclipse8.5中配置最基本的Hibernate的过程: 1,工具栏File->new->Java Project->工程命名,我这里是HibernateTest,其他都默认就好了->Finish 2,紧接着把数据库驱动加入classpath,方法前面...
本章除了讲解如何搭建源代码阅读环境,还介绍了Hibernate项目的基本配置、详细的实体映射配置等内容,详细的Hibernate项目配置将在第二章讲解。对于熟识Hibernate开发的读者,可以只看本章小结给出建议内容即可。1.2...
hibernate框架概述,环境搭建,hibernate基本配置,hibernate常用的几个API
针对hibernate中关于对象间的关联关系的配置
关于SpringMVC+Hibernate5项目配置,方便初学者使用,基本配置可以参看项目中的配置文件!
高级Hibernate4开发技术:ORM思想,hibernate介绍,hibernate.cfg.xml配置,hbm.xml映射文件详解,主键生成策略使用,PO对象状态及状态的转换分析、一级缓存,Hibernate数据检索技术,Hibernate高级映射技术,...
通过比较详细的步骤介绍了Eclipse中配置和使用Hibernate框架,并有一个简单例子实现,容易上手!
hibernate基本知识点,里面有关于hibernate的配置说明,hibernate的讲解