Java: Difference between revisions
Jump to navigation
Jump to search
Line 57: | Line 57: | ||
</persistence-unit> | </persistence-unit> | ||
</persistence> | </persistence> | ||
</syntaxhighlight> | |||
===Web.xml=== | |||
Started by the container to listen for context events<br /> | |||
<syntaxhighlight lang="xml"> | |||
<context-param> | |||
<param-name>contextConfiguration</param-name> | |||
<param-value>classPath:/jpaContext.xml</param-value> | |||
</context-param> | |||
<listener> | |||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> | |||
</listener> | |||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 01:03, 17 May 2020
JPA
This is a rough overview of configuration JPA with hibernate.
Pom.xml (Maven)
MySQL
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.20</version>
</dependency>
Hibernate
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>6.0.0.Alpha5</version>
<type>pom</type>
</dependency>
Jta
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
Spring Orm/JDBC
<dependency>
<groupId>springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>1.2.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.2.6.RELEASE</version>
</dependency>
Persistence.xml
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_2.xsd"
version="2.2">
<persistence-unit name="punit">
</persistence-unit>
</persistence>
Web.xml
Started by the container to listen for context events
<context-param>
<param-name>contextConfiguration</param-name>
<param-value>classPath:/jpaContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>