Like before based on the mapping file. Hbm.xml's Sessionfactory class is like this.
<span style= "Font-size:18px;color: #33CC00;" >private static sessionfactory sessionfactory; static{sessionfactory = new Configuration (). Configure (). Buildsessionfactory ();} </span>
The class Schemaexport that automatically generates the database schema is like this.
<span style= "Font-size:18px;color: #FF0000;" >schemaexport schemaexport = new Schemaexport (new Configuration (). Configure ()); Schemaexport.create (true,true); </span>
However, the notation-based Sessionfactory class is written like this
<span style= "Background-color:rgb (51, 255, 51); ><span style= "FONT-SIZE:18PX;" >static{sessionfactory = new Annotationconfiguration (). Configure (). Addpackage ("Com.test.hibernate"). Addannotatedclass (Car.class). Buildsessionfactory ();} </span></span>
And then the database automatically generates schema for the schemaexport.
<span style= "Background-color:rgb (51, 255, 51); ><span style= "FONT-SIZE:18PX;" >schemaexport schemaexport =new Schemaexport (New Annotationconfiguration (). Configure (). Addpackage (" Com.test.hibernate "). Addannotatedclass (Car.class)); Schemaexport.create (True,false);</span></span>
Hibernate the generation of annotations-based sessionfactory classes and the automatic generation of table Schemaexport classes