Hibernate4.x has been on the website for some time.
: http://hibernate.org/orm/downloads/
The jar package required to use Hibernate4 is in lib\required (required), the jar must be copied in the folder, and the other folder can have the optional copy;
1.buildSessionFactory
New Configuration (); // Sessionfactory factory = Config.buildsessionfactory ();
be returned below, or the introduction package will be error org.hibernate.HibernateException:Access to dialectresolutioninfo cannot is null when ' Hibernate.dialect ' Not set
New Configuration (). Configure (); @SuppressWarnings ("deprecation") new serviceregistrybuilder () . applysettings (Cfg.getproperties ()). Buildserviceregistry (); = Cfg.buildsessionfactory (serviceregistry);
2.annotation annotations
Org.hibernate.cfg.annotationconfiguration;deprecated. All functionality have been moved to configuration this annotation read configuration class has been deprecated, now read configuration does not need to specifically note is the annotation, directly with the configuration CFG = new Configuration (); You can read annotations. hibernate4.x version of the recommended use of annotation configuration, so when the introduction of the jar package requested inside the package all introduced to have already included the annotation must be wrapped
3. Auto-Build Table
New Configuration (). Configure (); New Schemaexport (CFT); Export.create (truetrue);
4. Database dialect settings
<name= "dialect" >org.hibernate.dialect.MySQL5Dialect</property> connecting to the MySQL database in version 3.3 only needs to indicate the Mysqldialect. In version 4.1, you can point out the Mysql5dialect
Hibernate4 use and new features