`
as619864232
  • 浏览: 321774 次
社区版块
存档分类
最新评论

hibernate 翻译

阅读更多

 

 

Configuration

An instance of Configuration allows(允许) the application to specify properties and mapping documents to be used when creating a SessionFactory. Usually(通常) an application will create a single Configuration, build a single instance of SessionFactoryand then instantiate Sessions in threads servicing client requests. The Configuration is meant(意味) only as an initialization(初始化)-time object. SessionFactorys are immutable(不可变) and do not retain(保留) any association(协会) back to the Configuration.

A new Configuration will use the properties specified in hibernate.properties by default.

NOTE : This will be replaced(取代) by use of ServiceRegistryBuilder and MetadataSources instead(替换) after the 4.0 release(发布) at which point this class will become deprecated and scheduled(预期) for removal in 5.0. See HHH-6183HHH-2578 and HHH-6586 for details

 

 

 

buildSessionFactory

Create a SessionFactory using the properties and mappings in this configuration. The SessionFactory will be immutable(不可变), so changes made to thisConfiguration after building the SessionFactory will not affect(影响) it.

 

 

 

 

SessionFactory

 

The main contract here is the creation of Session instances. Usually an application has a single SessionFactory instance and threads servicing(为...服务) client requests obtain(获得) Session instances from this factory.

The internal state of a SessionFactory is immutable. Once it is created this internal state is set. This internal state includes all of the metadata(元数据) about Object/Relational(相关的) Mapping.

Implementors(实施者must be threadsafe.

 

 

 

 

 

 

Session

 

The main runtime interface between a Java application and Hibernate. This is the central API class abstracting the notion(概念) of a persistence(持续) service.

The lifecycle(生命周期) of a Session is bounded(有界限的) by the beginning and end of a logical transaction. (Long transactions might(可能) span(跨越) several(几个) database transactions.)

The main function of the Session is to offer(提供) create, read and delete operations for instances of mapped entity classes. Instances may exist in one of three states:

transient(瞬时): never persistent(持久的), not associated(相关) with any Session

persistent(持久): associated(关联) with a unique Session
detached(托管): previously(预先) persistent, not associated with any Session

Transient(瞬时) instances may be made persistent(持久) by calling save()persist() or saveOrUpdate(). Persistent(持久) instances may be made transient by calling delete(). Any instance returned by a get() or load() method is persistent. Detached(托管) instances may be made persistent by calling update()saveOrUpdate()lock() orreplicate(). The state of a transient(瞬时) or detached(瞬时) instance may also be made persistent(持久) as a new persistent(持久) instance by calling merge().

save() and persist() result in an SQL INSERTdelete() in an SQL DELETE and update() or merge() in an SQL UPDATE. Changes to persistent instances are detected at flush time and also result in an SQL UPDATEsaveOrUpdate() and replicate() result in either an INSERT or an UPDATE.

It is not intended that implementors be threadsafe. Instead each thread/transaction should obtain its own instance from a SessionFactory.

Session instance is serializable if its persistent classes are serializable.

A typical transaction should use the following idiom:

 Session sess = factory.openSession();
 Transaction tx;
 try {
     tx = sess.beginTransaction();
     //do some work
     ...
     tx.commit();
 }
 catch (Exception e) {
     if (tx!=null) tx.rollback();
     throw e;
 }
 finally {
     sess.close();
 }
 


If the Session throws an exception, the transaction must be rolled back and the session discarded. The internal state of the Session might not be consistent with the database after the exception occurs.

分享到:
评论

相关推荐

    hibernate官网中文翻译版

    hibernate官网中文翻译版 便于大家学习hibernate

    Hibernate 和 NHibernate资料

    包括:Hibernate翻译版,Hibernate原理与配置快速入门,实战C#.NET编程----Spring.NET & NHibernate从入门到精通 三个pdf文档。

    hibernate-jpa-2.1-api-1.0.2.Final-API文档-中文版.zip

    包含翻译后的API文档:hibernate-jpa-2.1-api-1.0.2.Final-javadoc-API文档-中文(简体)版.zip; Maven坐标:org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.2.Final; 标签:hibernate、javax、...

    hibernate-jpa-2.1-api-1.0.2.Final-API文档-中英对照版.zip

    包含翻译后的API文档:hibernate-jpa-2.1-api-1.0.2.Final-javadoc-API文档-中文(简体)-英语-对照版.zip; Maven坐标:org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.2.Final; 标签:hibernate、...

    hibernate中文文档

    hibernate api 中文翻译 hibernate api 中文翻译 hibernate api 中文翻译

    Hibernate中文开发参考文档

    Hibernate版本3的翻译由满江红翻译团队(RedSaga Translate Team)集体进行,这也是一次大规模网络翻译的试验。在不到20天的时间内,我们完成了两百多页文档的翻译,这一成果是通过十几位网友集体努力完成的。通过这次...

    Hibernate相关英文翻译

    :最近我开始使用Eclipse作为我的开发环境,我开始研究其他人提供的对Eclipse的扩展。例如,当用到xml文件时,我使用XMLBuddy插件.在这篇文章中,我们将探索其中之一:Hibernate Synchronizer.。

    hibernate shards中文文档

    这是hibernate shards的中文翻译文档,hibernate shards是支持数据库水平分区的,它算是弥补hibernate的一个弱点吧

    hibernate_annotations翻译文档

    本文档的翻译是在网络上协作进行的,也会不断根据HIBERNATE的升级进行更新。

    Hibernate+中文文档

    1. Hibernate v3翻译团队 3.1. Hibernate JDBC属性 3.2. Hibernate数据源属性 3.3. Hibernate配置属性 3.4. Hibernate JDBC和连接(connection)属性 3.5. Hibernate缓存属性 3.6. Hibernate事务属性 3.7. 其他...

    Hibernate中文参考

    满江红翻译团队 翻译的hibernate参考文档

    Hibernate 4.1.1中文文档

    Hibernate 4.1.1 中文文档 是对官方文档进行了翻译,里面详细的介绍了Hibernate的特性,使用方法。还有很多的示例展示如何进行对象与数据库表之间的关系映射。

    MyEclipse Hibernate 快速入门中文版

    摘要: 是位于帮助文件中的 MyEclipse Hibernate Quickstart 的中文翻译

    Hibernate5.0用户手册中文版本

    hibernate5.0 翻译文档,按照英文原文翻译。纯java的关系型持久层框 .

    hibernate3.2中文文档(chm格式)

    1. Hibernate v3翻译团队 3.1. Hibernate JDBC属性 3.2. Hibernate数据源属性 3.3. Hibernate配置属性 3.4. Hibernate JDBC和连接(connection)属性 3.5. Hibernate缓存属性 3.6. Hibernate事务属性 3.7. 其他...

    HibernateAPI中文版.chm

    1. Hibernate v3翻译团队 3.1. Hibernate JDBC属性 3.2. Hibernate数据源属性 3.3. Hibernate配置属性 3.4. Hibernate JDBC和连接(connection)属性 3.5. Hibernate缓存属性 3.6. Hibernate事务属性 3.7. 其他...

    Hibernate中的query 分页.doc

    然后Hibernate会自动根据所设置的数据库方言翻译成相应的SQL语句提交给数据库。比如如果数据库是Oracle,SQL Server等,则翻译为类似select ... top 10之类的SQL语句,若是MySQL,则翻译为select ... limit 10之类的...

    MyEclipse+Hibernate快速入门中文版

    该文档详细讲述了在Myeclipse环境下的Hibernate配置方法,在文章的最后还给出了一个demo,是初学hibernate的利器。中文版更有利于大家的理解,翻译的还是很不错的。

    hibernate 教程

    翻译说明 1. 在Tomcat中快速上手 1.1. 开始Hibernate之旅 1.2. 第一个可持久化类 1.3. 映射cat 1.4. 与猫同乐 1.5. 结语 2. 体系结构 2.1. 总览 2.2. JMX集成 2.3. JCA支持 3. ...

    hibernate_reference(中文文档)

    hibernate_reference(中文文档),是一个翻译不错的中文Hibernate文档,全面详细的介绍了Hibernate的核心用法与原理

Global site tag (gtag.js) - Google Analytics