/ Published in: XML
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
Below diagram shows Java code for Hibernate settings equivalent to hibernate.cfg.xml's properties
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>net.javaguides.hibernate</groupId> <artifactId>hibernate-tutorial</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>hibernate-java-config-example</artifactId> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.13</version> </dependency> <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>5.3.7.Final</version> </dependency> </dependencies> <build> <sourceDirectory>src/main/java</sourceDirectory> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.5.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> </project>
URL: https://www.interviewqueries.com/hibernate-interview-questions-and-answers/