作者:empty 页数:398 出版社:empty |
Working ui th both Object-Oriented software and Relational Databases can be cun bers oneand time con sun ing.Do velop nent costs are significantly higher due to a paradigm ni snatchbe tue en how data is represented in oh jects versus rol ational databases, Hibernate is anObject/Relational Mapping solution for Java environments, The term Object/RelationalMapping refers to the to chn iq uc of mapping data fron an object model representation toa relational data no del representation{and visa versa) .Sechttp://on-vikipedia.org/wiki/Oh.ject-relational_uap ping for ago nd high-level discussion-Hibernate not only takes care of the mapping from Java classes to database tables f andfron Java datatypes to SQL datatypes) , but also provides data query and retrievalfacilities.Tt can significantly reduce development tine otherwise spent with n anualdata handling in SQL and JDBC.H liber nate's design goal is to relieve the developerfron 95%of com non data persistence-related program ning tasks by elini nating the needfor manual, hand-crafted data processing using SQL and JDBC, However, unlike n any otherpersistence solutions, Hibernate does not hide the power of SQL from you and guaranteesthat your invest nent in relational technology and kno ul edge is as valid as always.Hibernate may not be the best solution for data-centric applications that only usestored-procedures to fmp len ent the business logic in the database, it is most usefului th object-oriented domain models and business logic in the Java-based nid die-tier,Hov ever, Hibernate can certainly help you to remove or encapsulate vendor-specificSQLcode and will help with the common task of resultset translat f on from a tabularrepresentation to a graph of objects.
如果你对Ii bernat e和对象/关系型数据库映射还是个新手, 甚至对Java也不熟悉, 请按照下面的步骤来学习。1.Read第1章教程for a tutorial with step-by-step instructions.The sourcecode forthe tutorial is included En the distribution in the doc/reference/Lu torial/directory.2.Read第2章体系结构Archit actu re) to understand the environments where Hibernatecan be us od.前言3.查看Hibernate发行包中的e/目录, 里面有个一简单的独立运行的程序·把你的J DEC驱动复制到111/目录井修改一下ete/ht bar nate.properties.指定数据库的信息·然后进入命今行, 切换到发行包的目录, 输入an tag(使用Ant) , 或者在Windows系统下使用tu il deg4.Use this reference documentation as your pri nary source of information.Considerreading[d Pul] if you need more help with application design, or if you prefer astep-by-step tutorial.Alsovisithttp://caveateriptor.bibernate.nrganddaunloadtheexample applica Lion from[JP uH] .5.在Hibernate网站上可以找到问题和解答(FAQ) *6.在Hibernate网站上还有第三方的演示、示例和教程的链接。7.Hibernate网站的社区是讨论关于设计模式以及很多整合方案(Tomcat、JBossAs、Struts、EJB等) 的好地方·There area nunherofuaystobecone involved in the Hibernate community, including·Trying stuff out and reporting bugs.Seehttp://hibernateorg/issuetracker.htnldetails..Trying your hand at fixings one bugs or implementing enhancements.Again, see http://hibernate.org/issuetracker.htmldetails.·http://hibernale.org/comnunity.htnllistafeuwaysLoengageinLhecommunity.·Thore are for uns for us ors to as kquostionsandroceivoholp front he community..There are also IRC「http://en.wikipedia.org/wiki/Internet_Relay_Chat]channelsfor·Helping improve or translate this doc un entation, Contact us on the developer mailing.Evangelizing Hibernate within your organization.
面向新用户, 从一个简单的使用内存数据库的例子开始, 本章提供对Hibernate的逐步介绍。本教程基于Michael Gloeg l早期编写的手册·所有代码都包含在unto rials/neb目录下,1.1.第一部分-第一个Hibernate应用程序在这个例子里, 我们将设立一个小应用程序可以保存我们希望参加的活动(events) 和这些活动主办方的相关信息。(译者注:在本教程的后面部分, 我们将直接使用event而不是它的中文翻译“活动”,以免混滑。)
1.教程.
1.1.第一部分-第一个l liber nate应用程序
1.3.第三部分-Event Manager web应用程序.
3.7.Imple fen tinga Per sister Class Provider
1.1.1.设置.
1.1.2.第一个class.
1.1.3.映射文件.
1.1.4.Hibernate配置
1.1.5.用Maven构建
1.1.6.启动和辅助类.
1.1.7.加栽并存储对象.
1.2.第二部分一关联映射.
1.2.1.映射Person类
1.2.2.单向Set-based的关联
1.2.3.使关联工作.
3.9.1.事务策略配置.
3.9.2.JNDI绑定的SessionFactory
1.2.4.值类型的集合.
1.2.5.双向关联.
1.2.6.使双向连起来.
1.3.1.编写基本的servlet.
1.3.2.处理与渲染.
1.3.3.部器与测试.
1.4.总结.
2.1.概况(Overview).
3.1.可编程的配置方式.
3.4.1.SQL方言.
3.6.实现Naming Strategy.
2.体系结构(Archilec1ure)
2.1.1.Minimal archi tee turo
2.1.2.Compr chen si year chi tee ture
2.1.3.Basic APIs.
2.2.JMX整合.
2.3.上下文相关的会话(Contextual Session)
3.配置.
3.2.获得SessionFactory.
3.3.JDBC连接.
3.4.可选的配置属性.
3.5.日志.
HIBERNATE-Relational Persis.
4.持久化类(Persistent Classes)
5.对象/关系数据库映射基础《BasicO/R Mapping)
3.4.2.外连接抓取(Outer Join Fetching)
3.4.3.二进制流i Binary Streams.
3.4.4.二级缓存与查询缓存.
3.4.5.查询语言中的替换,.
3.4.6.Hibernate的统计(statist fcs) 机制.
3.8.XML配置文件.
3.9.Java EE ApplicationServer integration
3.9.3.在JTA环境下使用Current Session context(当前session上下文)
管理.
3.9.4.JMX部.
4.1.一个简单的F OJO例子.
4.2.实现继承(Inheritance)
4.1.1.实现一个默认的(即无参数的) 构造方法(constructor)
4.1.2.Provi do an identifier property.
4.1.3.Prefer non-final classes(seni-optional) .
5.1.1.Entity.
5.1.2.Identifiers
5.1.3.Optimistic locking properties(optional)
5.1.4.Property.
5.1.5.En bed dod obj oct s(aka components)
5.1.6.Inheritance strategy.
5.1.7.Mapping one to one and one to many a
5.1.8.自然ID(natural-id).
5.1.9.Any.
5.1.10.属性(Properties)
5.1.11.S one hba.xml specificities
5.2.1.实体(Entities) 和值(value a)
5.2.2.基本值类型.
5.2.3.自定义值类型.
6.1.1.Basic value types.
6.1.2.Composite types.
4.1.4.为持久化字段声明访问器t accessors) 和是否可变的标志(mutators)
4.3.实现equa1s 0和hashCode O方法55
4.4.动志模型(Dynamic mode1s)56
4.5.元组片断映射(T up liz ers)58
4.6.EntityName Resolvers.59
5.1.映射定义(Mapping declaration).63
5.2.Hibernate的类型.
5.3.多次映射同一个类.
5.4.SOL中引号包围的标识符.
5.5.数捷库生成属性(Generated Properties)
5.6.Column transformers:read and write express f on 8
5.7.辅助数据库对象(Auxiliary Database Obd ects)
6.Typos.i 1.0
6.1.Value types.
6.2.Entity type n.
6.3.Significance of type categories.
6.4.Custon types.
6.5.Type regis lry.
7.1.持久化集合类(Persistent collections)
6.4.1.Custo types using org.hibernate.type.Type
10.1.1.每个类分层结构一张表(Table per class hierarchy)
10.1.2.每个子类一张表(Table per subclass).
10.1.3.每个子类一张表{Tableper
(Discr in in aL or)
10.1.4.混合使用“每个类分层结构一张表”和“每个子类一张表”
10.1.5.每个具体类一张表(Table per concrete class
10.1.6.每个具体类一张表,使用隐式多态.
10.1.7.隐式多态和其他继承映射混合使用.
11.4.1.执行查询.2
11.4.2.过滤集合.
11.4.3.条件查询f Criteria queries)
12.1.1.Entities of immutable clas8e.
12.1.2.Loading persistent entitle gss read-on1y
12.1.3.Loading read-on1yentitiesfronanIQL query/criteria
12.1.4.Making a persistent entity read-only.
12.2.1.Simple propertie a
12.2.2.Unidirectional associations
12.2.3.Bidirectional associations.
13.1.1.操作单元(Unit of work)
13.1.2.长对话.
6.4.2.Cust am types using org.hibernate.user type.User Type.
7.2.Howto map collections.
7.3.高级集合映射(Advanced collection mappings)
7.4.集合例子(Call ection example)
8.2.单向关联(Unidir ee tional associations)
8.3.使用连接表的单向关联(Unidirectional associations with join tables)
8.4.双向关联(Bidirectional a sao ciations/
8.5.使用连接表的双向关联《Bidirectional associations with do in tables).188
8.6.更复杂的关联映射.190
9.1.依粮对象(Dependent obd ects).193
9.2.在集合中出现的依赖对象(Collections of dependent obd ects).195
9.3.组件作为Xap的索引(Components as Map indices).,196
9.4.组件作为联合标识符(Components as composite identifiers).196
9.5.动态组件(Dynamic components)198
6.4.3.Custon types using org.hibernate.user type.Camp a site User Type.
7.2.1.集合外键(Collection To reign keys).
7.2.2.索引集合类(Indexed collections)
7.2.3.Collections of has ic types and embeddable ph, jects
7.3.1, 有序集合{Sorted collections)
7.3.2.双向关联(Bidirectional associations)
7.3.3.双向关联,罗及有序集合类.
7.3.4.三重关联(Ternary associations)
7.3.5.Using an cid bag?.
8.2.1.多对一(many-to-one)
8.2.2.一对一(One-to-one)
8.2.3.一对多(one-to-many).
8.3.1.一对多(one-to-many).183
8.3.2.多对一(many-to-one)184
8.3.3.一对一(One-to-one)184
8.3.4.多对多(many-to-many).185
8.4.1.一对多(one ton any) /多对一(n any to one)186
8.4.2.一对一(One-to-one).187
8.5.1.一对多(one ton any) /多对一(n any to one)188
8.5.2.一对一(one to one)189
8.5.3.多对多(many-to-many)190
10.1.三种策略.-.201
10.2.限制.206
11.1.Hibernate对象状态(ob.ject states)20g
11.2.使对象持久化.209
11.3.装载对象.210
11.4.查询.212
11.4.4.使用原生SQL的查询.217
11.5.修改持久对象.218
11.6.修改脱管(Detached) 对象218
11.7.自动状态检测.219
11.8.删除持久对象.220
11.9.在两个不同数据库间复制对象.221
11.10.Session刷出(I lush).221
11.11.传播性持久化transitive persistence).222
11.12.使用元数据.225
12.1.Making persistent entities read-only.228
12.2.Read-only affect on property type.232
13.1.Sess f on和事务范围(transaction scope).,237
7.集合映射(Collection mappings)
8.关联关系映射.
8.1.介绍.
9.组件(Component) 映射.
HIBERNATE-Relational Persis.
10.继承映射(Inheritance Mapping)
11.与对象共事.
12.Read-only entities.
13.事务和并发.
13.1.3.关注对象标识(Considering ob, ject identity)
13.1.4.常见问题.
13.2.数据库事务声明
13.3.乐观并发控制(Op lim is Lic concurrency con l rol.
13.4.非观锁定(Pessin istic Locking
13.5.连接释放模式(Connection Release Modes)
14.1.拦截器(Interceptors)
1