User Tools

Site Tools


jpa

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

jpa [2020/07/19 07:11] (current)
admin created
Line 1: Line 1:
 +Jpa is a java framework to manage relational database records as plain java objects.
 +
 +It can be confirured (if you are using [[maven]] and spring boot) in the pom file, with the following dependencies:​
 +
 +  <​dependency>​
 +  <​groupId>​org.springframework.boot</​groupId>​
 +  <​artifactId>​spring-boot-starter-data-jpa</​artifactId>​
 +  </​dependency>​
 +
 +And you will need to specify a database, for example:
 +
 +  <​dependency>​
 +  <​groupId>​mysql</​groupId>​
 +  <​artifactId>​mysql-connector-java</​artifactId>​
 +  <​scope>​runtime</​scope>​
 +  </​dependency>​
 +
 +Or
 +
 +  <​dependency>​
 +  <​groupId>​com.h2database</​groupId>​
 +  <​artifactId>​h2</​artifactId>​
 +  <​scope>​runtime</​scope>​
 +  </​dependency>​
 +
 +In addition, you have to configure some properties, that can be done in the properties file or by java code. In the property file would be:
 +
 +  # JPA (JpaBaseConfiguration,​ HibernateJpaAutoConfiguration)
 +  #​spring.jpa.properties.hibernate.default_schema=sql7351295
 +  spring.jpa.properties.hibernate.format_sql=true
 +  spring.jpa.properties.hibernate.generate_statistics=true
 +  #to generate the tables, fields and other ddl structures if they are not present
 +  spring.jpa.hibernate.ddl-auto=update
 +  #to transform the hql queries in sql to be seen in the logfile
 +  spring.jpa.show-sql=true
 +
 +  #to use a h2 in memmory embedded database
 +  spring.datasource.url=jdbc:​h2:​mem:​testdb
 +  #to use a h2 file database
 +  #​spring.datasource.url=jdbc:​h2:​file:/​data/​demo
 +  spring.datasource.driverClassName=org.h2.Driver
 +  spring.datasource.username=sa
 +  spring.datasource.password=password
 +  spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
 +
  
jpa.txt ยท Last modified: 2020/07/19 07:11 by admin