- Click on Project root and Add Framework Support... or download Hibernate_release.zip(ORM) from http://hibernate.org
- Click Hibernate from list and Select download and ok
- Open Module Setting and inside Modules select hibernate and add configuration file "hibernate.cfg.xml"
- The hibernate configuration file will be added to
src > resources
. Open the file and paste the following codes if you are using MYSQL database<session-factory> <!-- Database connection settings --> <property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://localhost:3306/**DATABASE_NAME**</property> <property name="connection.username">root</property> <property name="connection.password"></property> <!-- JDBC connection pool (use the built-in) --> <property name="connection.pool_size">5</property> <!-- SQL dialect --> <property name="dialect">org.hibernate.dialect.MySQL5Dialect</property> <!-- Echo all executed SQL to stdout --> <property name="show_sql">true</property> <!-- Drop and re-create the database schema on startup --> <property name="hbm2ddl.auto">create</property> <!--For existing database--> <!--<property name="hbm2ddl.auto">validate</property>--> <!-- Names the annotated entity class --> <mapping class="com.**Location.to.Model**"/> </session-factory>
- Change Database name and Location to Model
- Download Mysql-connector jar file from https://mvnrepository.com/artifact/mysql/mysql-connector-java
- Place it inside lib folder (Both Compile and Runtime Lib) and add it to the library.
Last active
June 22, 2017 13:36
-
-
Save somecuitears/d57fbf2a9ed06964c1abcef0989718cd to your computer and use it in GitHub Desktop.
Hibernate Configuration with Spring
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment