Hibernate进阶之路—-Hibernate API

目录

1.SessionFactory

1.SessionFactory (org.hibernate.SessionFactory)

1.1.overview

  • thread-safe
  • 单数据库
  • 保存编译后mappings,不可变
  • org.hibernate.Session的工厂
  • org.hibernate.connection.ConnectionProvider的客户类

1.2.创建

Configuration configuration = new Configuration();
configuration.configure();
SessionFactory sessionFactory = configuration.buildSessionFactory();

可以为每个数据库创建一个SessionFactory对象
SessionFactory对象创建后Configuration对象将被丢弃

Session (org.hibernate.Session)

  • 单线程
  • short-lived object
  • 应用程序和持久层间的会话
  • JDBC java.sql.Connection的包装
  • org.hibernate.Transaction的工厂
  • 维护应用程序和持久层的一级cache

Persistent objects and collections

  • JavaBean/POJO
  • Short-lived
  • 单线程
  • 只和一个org.hibernate.Session关联?

Transient and detached objects and collections

  • 未和Session关联的持久化类的对象

Transaction (org.hibernate.Transaction)

  • single-threaded
  • short-lived object
  • JDBC, JTA or CORBA transaction的抽象

ConnectionProvider (org.hibernate.connection.ConnectionProvider)

  • JDBC connections的工厂及池
  • DataSource或DriverManager的抽象

TransactionFactory (org.hibernate.TransactionFactory)

  • org.hibernate.Transaction的工厂
  • 不暴露给application, 可extend 或 implements

Extension Interfaces

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s