hibernate4.0一些变化

 

This document is a work in progress as we develop 4.0

 

  1. Initial move to ServiceRegistry.  For now, see design wikis or sources for more information.  Not all "services" have been migrated to this model yet.  The main ones (JDBC and transaction stuff) as well as lowever level one (classloading and such) have been migrated.  The rest will be moved during Alpha2 development.
  2. In an initial push toward osgi we started splitting up packages a little bit differently in this release. 
    1. The reason is to identify classes which are intended as
      1. public API, which are fully expected to be used in application code.
      2. internal implementation details, which are only intended for Hibernate use.
      3. SPI contracts, whch define
        1. extension contracts
        2. contracts with Hibernate internals exposed to these extensions
    2. This will potentially lead to some  packaging changes needed in user code:
      1. org.hibernate.dialect.resolver.DialectResolver -> org.hibernate.service.jdbc.dialect.spi.DialectResolver
  3. Deprecated methods that have been removed:
    1. References to org.hibernate.type.AbstractSingleColumnStandardBasicType and org.hibernate.type.SingleColumnType methods should be changed as indicated:
      1. nullSafeGet(ResultSet rs, String name) should be changed to 
        nullSafeGet(ResultSet rs, String name, SessionImplementor session)
      2. get(ResultSet rs, String name) should be changed to 
        get(ResultSet rs, String name, SessionImplementor session)
      3. nullSafeSet(PreparedStatement st, T value, int index) should be changed to nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session)
      4. set(PreparedStatement st, T value, int index) should be changed to set(PreparedStatement st, T value, int index, SessionImplementor session)
    2. References to org.hibernate.usertype.UserType methods should be changed as indicated:
      1. nullSafeGet(ResultSet rs, String[] names, Object owner) should be changed to   
        nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
      2. nullSafeSet(PreparedStatement st, Object value, int index) should be changed to nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session)
    3. Session.reconnect() - manual disconection and reconnection is now only supported for user-supplied-connection scenarios (JDBC Connection passed in while opening the Session)
    4. Session.connection() - use Session.doWork(), Session.doReturningWork() or Session.sessionWithOptions()...openSession() as replacement depending on need
    5. Most of the overloaded SessionFactory.openSession methods.  Use SessionFactory.withOptions()...openSession() instead
  4. Deprecated classes/interfaces that have been removed:
    1. org.hibernate.classic.Session
    2. org.hibernate.classic.Validatable
    3. org.hibernate.classic.ValidationException
  5. org.hibernate.jdbc.BatcherFactory, Batcher, and their implementations have been replaced by org.hibernate.engine.jdbc.batch.spi.BatchBuilder and Batch, with default implementations in org.hibernate.engine.jdbc.batch.internal. You can override the default BatchBuilder by defining the  "hibernate.jdbc.batch.builder" property as the name of a BatchBuilder implementation, or by providing a BatchBuilder in a custom ServiceRegistry.
  6. hibernate.cfg.xml no longer supported as means of specifying listeners.  New approach invloves using an org.hibernate.integrator.spi.Integrator which works based on "service discovery". 

 

Some other changes I noticed while migrated mappings example project to hibernate4:

  1. package org.hibernate.connection was removed
  2. Hibernate.INTEGER and other similar instances were removed and now IntegerType.INSTANCE should be used; another example is Hibernate.BINARY -> BitaryType.INSTANCE and etc.)
  3. org.hibernate.util.EqualsHelper moved to internal package org.hibernate.internal.util.compare.EqualsHelper
  4. SessionImplementor have lost getEntityMode() and to get it I use SessionImplementor.getEntityPersister().getEntityMode()
  5. org.hibernate.persister.entity.EntityPersister got new methods to implement
  6. EntityMode.MAP was removed
  7. Hibernate.entity(Class) was removed (didn't find really good way to migrate it to new version)

 

你可能感兴趣的:(Hibernate,object,session,String,jdbc,methods)