Hibernate project


/ Published in: XML
Save to your folder(s)

In this article, we will show you how to create a Hibernate Application using Java configuration without using hibernate.cfg.xml to connect the MySQL database.

Below diagram shows Java code for Hibernate settings equivalent to hibernate.cfg.xml's properties


Copy this code and paste it in your HTML
  1. <project
  2. xmlns="http://maven.apache.org/POM/4.0.0"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5. <modelVersion>4.0.0</modelVersion>
  6. <parent>
  7. <groupId>net.javaguides.hibernate</groupId>
  8. <artifactId>hibernate-tutorial</artifactId>
  9. <version>0.0.1-SNAPSHOT</version>
  10. </parent>
  11. <artifactId>hibernate-java-config-example</artifactId>
  12. <properties>
  13. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  14. </properties>
  15. <dependencies>
  16. <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
  17. <dependency>
  18. <groupId>mysql</groupId>
  19. <artifactId>mysql-connector-java</artifactId>
  20. <version>8.0.13</version>
  21. </dependency>
  22. <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
  23. <dependency>
  24. <groupId>org.hibernate</groupId>
  25. <artifactId>hibernate-core</artifactId>
  26. <version>5.3.7.Final</version>
  27. </dependency>
  28. </dependencies>
  29. <build>
  30. <sourceDirectory>src/main/java</sourceDirectory>
  31. <plugins>
  32. <plugin>
  33. <artifactId>maven-compiler-plugin</artifactId>
  34. <version>3.5.1</version>
  35. <configuration>
  36. <source>1.8</source>
  37. <target>1.8</target>
  38. </configuration>
  39. </plugin>
  40. </plugins>
  41. </build>
  42. </project>

URL: https://www.interviewqueries.com/hibernate-interview-questions-and-answers/

Report this snippet


Comments


You need to login to view comments.