dependencies: Fix #2297: Upgrade H2 (#2317)

* refactor: drop tables according to their dependencies

* refactor: renamed table because USER is an SQL keyword

* dep: upgrade com.h2database.h2 1.4.190 to 2.1.214
This commit is contained in:
Robert Volkmann
2022-11-20 13:25:33 +01:00
committed by GitHub
parent 465a6871b2
commit c4307db0a6
6 changed files with 10 additions and 16 deletions
@@ -60,8 +60,8 @@ public class App {
+ "customer_name varchar references CUSTOMERS(name));";
public static final String DELETE_SCHEMA_SQL =
"DROP TABLE CUSTOMERS IF EXISTS;"
+ "DROP TABLE PURCHASES IF EXISTS;"
"DROP TABLE PURCHASES IF EXISTS;"
+ "DROP TABLE CUSTOMERS IF EXISTS;"
+ "DROP TABLE PRODUCTS IF EXISTS;";
/**
+4 -4
View File
@@ -26,14 +26,14 @@ Wikipedia says
**Programmatic Example**
We give an example about visiting the information of `USER` table in `h2` database. Firstly, we create `USER` table with `h2`:
We give an example about visiting the information of `user_account` table in `h2` database. Firstly, we create `user_account` table with `h2`:
```java
@Slf4j
public class DatabaseUtil {
private static final String DB_URL = "jdbc:h2:mem:metamapping";
private static final String CREATE_SCHEMA_SQL = "DROP TABLE IF EXISTS `user`;"
+ "CREATE TABLE `user` (\n"
private static final String CREATE_SCHEMA_SQL = "DROP TABLE IF EXISTS `user_account`;"
+ "CREATE TABLE `user_account` (\n"
+ " `id` int(11) NOT NULL AUTO_INCREMENT,\n"
+ " `username` varchar(255) NOT NULL,\n"
+ " `password` varchar(255) NOT NULL,\n"
@@ -88,7 +88,7 @@ Then we write a `xml` file to show the mapping between the table and the object:
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.iluwatar.metamapping.model.User" table="user">
<class name="com.iluwatar.metamapping.model.User" table="user_account">
<id name="id" type="java.lang.Integer" column="id">
<generator class="native"/>
</id>
@@ -34,8 +34,8 @@ import org.h2.jdbcx.JdbcDataSource;
@Slf4j
public class DatabaseUtil {
private static final String DB_URL = "jdbc:h2:mem:metamapping";
private static final String CREATE_SCHEMA_SQL = "DROP TABLE IF EXISTS `user`;"
+ "CREATE TABLE `user` (\n"
private static final String CREATE_SCHEMA_SQL = "DROP TABLE IF EXISTS `user_account`;"
+ "CREATE TABLE `user_account` (\n"
+ " `id` int(11) NOT NULL AUTO_INCREMENT,\n"
+ " `username` varchar(255) NOT NULL,\n"
+ " `password` varchar(255) NOT NULL,\n"
@@ -4,7 +4,7 @@
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.iluwatar.metamapping.model.User" table="user">
<class name="com.iluwatar.metamapping.model.User" table="user_account">
<id name="id" type="java.lang.Integer" column="id">
<generator class="native"/>
</id>
-6
View File
@@ -38,7 +38,6 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sonar-maven-plugin.version>3.8.0.2131</sonar-maven-plugin.version>
<spring-boot.version>2.7.5</spring-boot.version>
<h2.version>1.4.190</h2.version>
<jacoco.version>0.8.8</jacoco.version>
<commons-dbcp.version>1.4</commons-dbcp.version>
<camel.version>2.25.1</camel.version>
@@ -232,11 +231,6 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
@@ -30,7 +30,7 @@ package com.iluwatar.transactionscript;
public final class RoomSchemaSql {
public static final String CREATE_SCHEMA_SQL =
"CREATE TABLE ROOMS (ID NUMBER, ROOM_TYPE VARCHAR(100), PRICE INT(100), BOOKED VARCHAR(100))";
"CREATE TABLE ROOMS (ID NUMBER, ROOM_TYPE VARCHAR(100), PRICE INT, BOOKED VARCHAR(100))";
public static final String DELETE_SCHEMA_SQL = "DROP TABLE ROOMS IF EXISTS";
private RoomSchemaSql() {