This is due to the fact that the serviceregistry in Hibernate 4.x and 5.x have different
Hibernate 4.x
1. Create a Sessionfactory object
Sessionfactory Sessionfactory=null;
2. Create a configuration object that must be based on your basic configuration information and mapping relationships
Configuration Config=new configuration (). Configure ();
3. To create a Session object
Session Session=null;
4. Hibernate 4.X is introduced into the Serviceregistry interface with the registration information
Serviceregistry bulidserviceregistry = new Serviceregistrybuilder (). Applysettings (Config.getproperties ()). Buildserviceregistry ();
. Applysettings (Config.getproperties ()). build ();
Sessionfactory = Config.buildsessionfactory (bulidserviceregistry);
5. Get session
Session = Sessionfactory.opensession ();
Hibernate 5.x does not have a serviceregistrybuilder () method, but instead replaces it with the Standardserviceregistrybuilder () method
Serviceregistry serviceregistry = new Standardserviceregistrybuilder (). Applysettings (Config.getproperties ()). Build ();
However, this method does not get the entity class, so it can be written directly
Sessionfactory sessionfactory = null;
Configuration config = new configuration (). Configure ();
Session session =null;
Serviceregistry serviceregistry = new Standardserviceregistrybuilder (). Applysettings (Config.getproperties ()). Build ();
Sessionfactory =config.buildsessionfactory ();
Session = Sessionfactory.opensession ();
This article is from the "12901799" blog, please be sure to keep this source http://12911799.blog.51cto.com/12901799/1927538
Hibernate error Org.hibernate.MappingException:Unknown entity: ....