Help

I apologize for the day delay. Ran into a small issue with one of my Gradle plugins after upgrading Gradle for the Hibernate build. Now that that is all sorted...

We are pleased to announce the release of Hibernate Core 4.0.0.Alpha3. Consult the change list for all the gory change details. This is scheduled to be the last Alpha release for Hibernate 4, Beta1 being slated for release on June 1st.

4.0.0.Alpha3 was really about continuing to work on the new metamodel code and fleshing out the new API for SessionFactory creation which leverages that metamodel code as well as the ServiceRegistty code introduced in the first Alpha (and cleaned up since). These things will continue to be the focus for Beta1 too as there is still lots of work to be done on the metamodel code and the SessionFactory building is inherently linked with that work. However, I think the API for SessionFactory building is pretty completely at this point. So I wanted to take the opportunity to introduce that API, even though it is not wired up at this time.

Currently you start off with a ServiceRegistry:

org.hibernate.service.BasicServiceRegistry serviceRegistry = new org.hibernate.service.ServiceRegistryBuilder()
        ... // configure the services
        buildServiceRegistry();

Configuration here means either providing services (or service initiators) directly or providing settings that the services will pick up.

Next, we collect up the metadata sources which are the various sources you want Hibernate to look for metadata describing your domain model and its mapping to the relational database. These sources might be hbm.xml files, annotated classes, etc:

org.hibernate.metamodel.MetadataSources metadataSources = new org.hibernate.metamodel.MetadataSources( serviceRegistry )
        .addResource( "some.hbm.xml" )
        .addAnnotatedClass( SomeEntity.class )
        ...;

An interesting thing to note here is that we now have a natural lifecycle to the information that used to just get dumped into org.hibernate.cfg.Configuration. This previous step only collects the metadata sources, we still need Hibernate to process them:

org.hibernate.metamodel.Metadata metadata = metadataSources.buildMetadata();

And then finally we build the SessionFactory:

SessionFactory sessionFactory = metadata.buildSessionFactory();

You can even chain many of these steps:

BasicServiceRegistry serviceRegistry = new ServiceRegistryBuilder()
        ... // configure the services
        buildServiceRegistry();

SessionFactory sessionFactory = new MetadataSources( serviceRegistry )
        .addResource( "some.hbm.xml" )
        .addAnnotatedClass( SomeEntity.class )
        .buildMetadata()
        .buildSessionFactory();

org.hibernate.cfg.Configuration has been deprecated in this release and org.hibernate.cfg.AnnotationConfiguration has been deprecated for some time now. Both will get removed before 4.0.0 goes Final. We are still planning exactly what the replacement for org.hibernate.ejb.Ejb3Configuration will look like, but it too has been deprecated in the meantime (the recommended way to build an EntityManagerFactory has always been via javax.persistence.Persistence anyway).

We got a lot more aggressive with the package reorganization in this release as well. For those unfamiliar, the general idea is that this is a sort of pre-osgi-ification step, so more will be coming on that front later. The basic gist is that we are splitting packages up based on usages. Stuff deemed part of the API will remain in their same packages, stuff making up the various SPIs will be moved to a 'spi' package, and finally internal (non-public) stuff is moved to an 'internal' package. This work is not yet done, but is moving along.

As always, if you have any comments, the best place is either the hibernate-dev mailing list or the #hibernate-dev IRC channel on freenode. Now is especially the time if you had ideas about any of the planned changes as we move towards 4.0.0.Final or wanted to help in the effort. We have development meetings weekly on the #hibernate-dev IRC channel Mondays at 10am Central time. We also send out minutes to the dev mailing list afterwards.

As always, the release is available from both SourceForge in bundle form as well as the JBoss Nexus repository under the org.hibernate groupId.

5 comments:
 
01. Jun 2011, 11:30 CET | Link

Hi,

I dint find the buildSessionFactory method in MetaData interface. Can you please advice??

ReplyQuote
 
26. Jan 2012, 10:44 CET | Link
"Both will get removed before 4.0.0 goes Final" - this doesn't seem to be the case, meaning Hibernate 4 was released, but these deprecated classes are still part of the package. Any idea why that is?
Regards.
Eugen.
 
27. Jan 2012, 15:43 CET | Link

Finishing the new metamodel code (upon which removal of both Configuration objects depends) was rescheduled for 5.0.

 
31. Jul 2014, 13:24 CET | Link
jack

The great thing about BuildAModule is how well the videos are organized, by far the easiest to use and most approachable website among all of these resources. The only disadvantage when lake worth dentist compared to Drupalize.me is that BuildAModule is a newer service that's not quite as established and credible, but the quality of the content is superb.

 
10. Oct 2014, 10:44 CET | Link

Groseille, mosstone ou la Reverso Bracelet accent beige est unique, chic, la mode des replique montres hors tension. Avec trois nouvelles couleurs, est devenu un fournisseur mondial de le 14 mai 2013. Reverso Jaeger-LeCoultre Reverso grande dame au grand bascules mince dames minces regardent comme un hommage aux rêves des femmes, regardent grande maison Reverso Reverso Lady Ultra-mince grande volte dames ultra-minces, comme d'habitude, copie sac est engagé au classique la nature de la montre Reverso, arts décoratifs et les femmes réplique Breitling Bentley combinaison parfaite de l'élégance.

Post Comment