Hibernate4 获取SessionFactory
import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder; public class Test { private static Configuration configuration = null;
private static SessionFactory sessionFactory = null;
private static ServiceRegistry serviceRegistry = null;
public static void main(String[] args) {
try {
configuration = new Configuration().configure();
serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
} catch (HibernateException e) {
e.printStackTrace();
}
} }
Hibernate4 获取SessionFactory的更多相关文章
- Hibernate4获取sessionFactory
/** * Location of hibernate.cfg.xml file. * Location should be on the classpath as Hibernate uses * ...
- 不同版本Hibernate.获取SessionFactory的方式
不同版本Hibernate.获取SessionFactory的方式 Hibernate 版本说明: 我当前使用的是 Hibernate 5.x ,(hibernate-release-5.3.6.Fi ...
- hibernate不同版本获取获取sessionFactory
hibernate4时,我们采用以下方式获取会话工厂: // 1. 解析我们在hibernate.cfg.xml中的配置 Configuration configuration = new Confi ...
- Hibernate4获取Connection,ResultSet对象
项目中需要一个json对象,封装的时候,需要数据的列名. 在jdbc里面,可以有个ResultMetaData对象获取列名字.因为我用的是hibernate,这个框架已经封装了很多,一般是难以获得re ...
- spring整合hibernate,在获取sessionFactory的时候报错,求解决办法!!
applicationContext.xml文件 <!-- 开启扫包 --> <context:component-scan base-package="cn.edu&qu ...
- 让我的分页类获取sessionFactory
我们知道在Hibernate里比较重要的sessionFactory,经过Spring的管理可以很好地为Spring里注入使用的bean服务(提供数据源的使用),但是,当我们所要使用的类不是像我们尝试 ...
- 4.0之后的hibernate获取sessionFactory
static{ Configuration config=new Configuration().configure(); ServiceRegistry resgistry = new Servic ...
- hibernate4.0中SessionFactory的创建
创建SessionFactory 首先创建Configuration对象,主要方式是: new Configuration().configure() 默认情况下Hibernate会去classPat ...
- 基于Spring4+Hibernate4的通用数据访问层+业务逻辑层(Dao层+Service层)设计与实现!
基于泛型的依赖注入.当我们的项目中有很多的Model时,相应的Dao(DaoImpl),Service(ServiceImpl)也会增多. 而我们对这些Model的操作很多都是类似的,下面是我举出的一 ...
随机推荐
- rtpMIDI Tutorial
Tobias Erichsen private stuff & software for audio, midi and more Search Main menu Skip to prima ...
- nopi excel 导入
#region 从Excel导入 /// <summary> /// 读取excel ,默认第一行为标头 /// </summary> /// <param name=& ...
- rsync一些安全的使用方法
总的来说,开在873端口之后,只要加上验证口令,安全性就有保障了,但毕竟多开一个端口,而且rsync的密码是明文方式存储的,相对来说,还是有被监听的可能.根据不同的情况采用下述不同方案,相对来说,安全 ...
- Qt qtextstream读取文件
今天发现一个很有用的类:qtextstream 这个类可以以文件句柄为构造函数 然后用readAll函数返回一个QString的字符串
- 通过样式class 判断多个checkbox redio 是否都选中
var count = "${count}"; for(var i=1;i<=count;i++){ var flag = false; if($("input[c ...
- 部署点评Cat监控项目(转)
原文地址:http://www.bubuko.com/infodetail-986338.html 在项目中监控代码运行的状况,可以采用点评的Cat项目来监控整个项目,但是按照官方的文档来部署cat, ...
- python 抓取百度音乐
# coding:utf-8 import urllib2 import re import urllib import chardet from json import * category = ' ...
- iOS不使用JSONKit做Dic到JsonString的转换
NSDictionary to jsonString [self DataTOjsonString:dic] -(NSString*)DicToJsonString:(id)object { NSSt ...
- CSS hack方式一览【转】
做前端多年,虽然不是经常需要hack,但是我们经常会遇到各浏览器表现不一致的情况.基于此,某些情况我们会极不情愿的使用这个不太友好的方式来达到大家要求的页面表现.我个人是不太推荐使用hack的,要知道 ...
- e
frame问题 以下面的frame为例: ? 1 <frame src=”xxx.html” id=”frameId” name=”frameName” /> (1)访问frame ...