hibernate4 使用及 新特性
hibernate4.x已经在官网出现一段时间了.
下载地址: http://hibernate.org/orm/downloads/
使用hibernate4所需要的jar包 在lib\required(必选的), 该文件夹中的jar必选都要copy,其他文件夹的可以有选择性的copy;
1.buildSessionFactory
Configuration config = new Configuration();//
SessionFactory factory = config.buildSessionFactory();
被下面退换,否则引入包会报错 org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
Configuration cfg = new Configuration().configure();
@SuppressWarnings("deprecation")
ServiceRegistry serviceRegistry = new ServiceRegistryBuilder()
.applySettings(cfg.getProperties()).buildServiceRegistry();
SessionFactory factory = cfg.buildSessionFactory(serviceRegistry);
2.annotation注解
org.hibernate.cfg.AnnotationConfiguration;
Deprecated. All functionality has been moved to Configuration
这个注解读取配置的class已经废弃,现在读取配置不需要特别注明是注解,直接用Configuration cfg = new Configuration();就可以读取注解。 Hibernate4.X版本中推荐使用annotation配置,所以在引进jar包时把requested里面的包全部引进来就已经包含了annotation必须包了
3.自动建表
Configuration cft = new Configuration().configure();
SchemaExport export = new SchemaExport(cft);
export.create(true, true);
4.数据库方言设置
<property name=”dialect”>org.hibernate.dialect.MySQL5Dialect</property>
在3.3版本中连接MySQL数据库只需要指明MySQLDialect即可。在4.1版本中可以指出MySQL5Dialect
hibernate4 使用及 新特性的更多相关文章
- JBOSS EAP 6 系列一 新特性
在项目中,采用的架构是Springmvc+spring+EJB+Jpa等架构,当然服务器是Jboss,本次Jboss我们采用的是JBossEap6.2,Jboss7的新特性与Jboss4.5的大的改变 ...
- Atitit hibernate3 hinernate4 hibernate5新特性attilax总结
Atitit hibernate3 hinernate4 hibernate5新特性attilax总结 1.1. Hibernate3的新特性 1 1.2. hibernate4.1版本中的新特性和h ...
- SQL Server 2014 新特性——内存数据库
SQL Server 2014 新特性——内存数据库 目录 SQL Server 2014 新特性——内存数据库 简介: 设计目的和原因: 专业名词 In-Memory OLTP不同之处 内存优化表 ...
- ElasticSearch 5学习(10)——结构化查询(包括新特性)
之前我们所有的查询都属于命令行查询,但是不利于复杂的查询,而且一般在项目开发中不使用命令行查询方式,只有在调试测试时使用简单命令行查询,但是,如果想要善用搜索,我们必须使用请求体查询(request ...
- [干货来袭]C#6.0新特性
微软昨天发布了新的VS 2015 ..随之而来的还有很多很多东西... .NET新版本 ASP.NET新版本...等等..太多..实在没消化.. 分享一下也是昨天发布的新的C#6.0的部分新特性吧.. ...
- CSS3新特性应用之结构与布局
一.自适应内部元素 利用width的新特性min-content实现 width新特性值介绍: fill-available,自动填充盒子模型中剩余的宽度,包含margin.padding.borde ...
- 【译】Meteor 新手教程:在排行榜上添加新特性
原文:http://danneu.com/posts/6-meteor-tutorial-for-fellow-noobs-adding-features-to-the-leaderboard-dem ...
- 跨平台的 .NET 运行环境 Mono 3.2 新特性
Mono 3.2 发布了,对 Mono 3.0 和 2.10 版本的支持不再继续,而且这两个分支也不再提供 bug 修复更新. Mono 3.2 主要新特性: LLVM 更新到 3.2 版本,带来更多 ...
- Atitit opencv版本新特性attilax总结
Atitit opencv版本新特性attilax总结 1.1. :OpenCV 3.0 发布,史上功能最全,速度最快的版1 1.2. 应用领域2 1.3. OPENCV2.4.3改进 2.4.2就有 ...
随机推荐
- remove all .git files and directories use one command
find . -type d -name ".git" | xargs rm -rf
- NSURLConnection & NSRULSession
NSURLConnection & NSRULSession NSURLSession是NSURLConnection 的替代者,在2013年苹果全球开发者大会(WWDC2013)随ios7一 ...
- <c:forEach> 详解
<c:forEach>标签用于通用数据循环,它有以下属性 属 性 描 述 是否必须 缺省值 items 进行循环的项目 否 无 begin 开始条件 否 0 end 结束条件 否 集合中的 ...
- 移动端 viewport设置
<meta name="viewport" content="" /> width [pixel_value | device-width] wid ...
- Umbraco(3) - CSS & Javascript(翻译文档)
原文地址:http://www.ncloud.hk/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/umbraco3css-javascript/ CSS & Jav ...
- WGS84坐标系下,经纬度如何换算成米
参考博客:显示瓦片地图 http://www.cnblogs.com/rhinoxy/p/4995731.html 注意:这里的计算方法精度相差比较大,不满足精确计算的需要. 需要理解的GIS概念: ...
- Differential Geometry之第五章曲面的内蕴几何学
第五章.曲面的内蕴几何学 1.曲面的等距变换 2.曲面的协变微分 协变微分: 3.测地曲率与测地线 4.测地坐标系 4.1.测地平行坐标系 4.2.测地极坐标系和法坐标系 5.Gauss-Bonnet ...
- MongoDB - The mongo Shell, Configure the mongo Shell
Customize the Prompt You may modify the content of the prompt by setting the variable prompt in the ...
- 【Mongodb】---基本命令
show dbs:显示数据库列表 show collections:显示当前数据库中的集合(类似关系数据库中的表) show users:显示用户 use <db name>:切换当前数据 ...
- SQL Server 日志清除
在SqlServer中清除日志就必须在简单模式下进行,等清除动作完毕再调回到完全模式. *[DataBaseName]要压缩日志的数据库名称. 设置数据库模式为简单模式 ALTER DATABASE ...