---
title: "Hibernate 接口和配置文件"
author: "xycdgc"
date: "2010-04-12T23:58:04Z"
tags: ["Cache", "Hibernate", "JSP", "SQL", "XML"]
categories: ["企业架构"]
slug: "hibernate"
draft: false
lastmod: "2010-04-27T15:57:46Z"
id: 642294
url: "https://xycdgc.iteye.com/blog/642294"
---

Hibernate核心接口位于业务层和持久化层，核心接口总共有5个，分别是Session,SessionFactory,Configuration,Transaction和Query. (1)接触Session要和JSP应用中HTTPSession分开，后者的Session是用户Session. (2)SessionFactory接口负责初始化Hibernate. (3)Configuration接口负责配置并启动Hibernate。 (4)Transaction接口负责事务的相关操作。 (5)Query接口负责执行各种数据库的查询。 Hibernate的配置文件有两种形式：一种是xml格式的，另外的一个是properties属性文件。自己偏向于xml文件的配置，Hibernate配置文件默认文件名是hibernate.cfg.xml 基本的格式是： 数据库的驱动 相应的url 数据库用户名 密码 连接池 方言 thread org.hibernate.cache.NoCacheProvider 是否显示出sql语句 create