Convert querydsl-example-sql-guice to use h2 memory db

This commit is contained in:
John Tims 2020-05-29 09:17:08 -06:00
parent 7aca02c288
commit f7bbee1c8a
5 changed files with 36 additions and 7 deletions

View File

@ -11,7 +11,7 @@
<property name="hibernate.connection.driver_class" value="org.h2.Driver" />
<property name="hibernate.connection.url" value="jdbc:h2:./target/h2-hibernate" />
<property name="hibernate.connection.user" value="sa" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.flushMode" value="FLUSH_AUTO" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.ehcache.EhCacheRegionFactory" />

View File

@ -18,7 +18,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<failIfNoTests>false</failIfNoTests>
<guice.version>3.0</guice.version>
<h2.version>1.3.170</h2.version>
<h2.version>1.4.186</h2.version>
</properties>
<dependencies>
@ -115,7 +115,7 @@
</executions>
<configuration>
<jdbcDriver>org.h2.Driver</jdbcDriver>
<jdbcUrl>jdbc:h2:${project.basedir}/h2</jdbcUrl>
<jdbcUrl>jdbc:h2:mem:;INIT=runscript from 'file:${project.baseUri}/src/main/sql/001_schema.sql'</jdbcUrl>
<jdbcUser>sa</jdbcUser>
<packageName>com.querydsl.example.sql.model</packageName>
<targetFolder>${project.basedir}/target/generated-sources/java</targetFolder>

View File

@ -1,4 +1,4 @@
jdbc.url = jdbc:h2:h2
jdbc.user = sa
jdbc.password =
jdbc.driver = org.h2.Driver
jdbc.url=jdbc:h2:mem:testdb;INIT=runscript from 'src/main/sql/001_schema.sql'
jdbc.user=sa
jdbc.password=
jdbc.driver=org.h2.Driver

View File

@ -0,0 +1,29 @@
create schema if not exists PUBLIC;
create table if not exists LOCATION
(
ID BIGINT auto_increment primary key,
LATITUDE DOUBLE,
LONGITUDE DOUBLE,
);
create table if not exists USER
(
ID BIGINT auto_increment primary key,
USERNAME VARCHAR(255)
);
create table if not exists TWEET
(
ID BIGINT auto_increment primary key,
CONTENT VARCHAR(255),
LOCATION_ID BIGINT,
POSTER_ID BIGINT not null,
);
create table if not exists TWEET_USER
(
TWEET_ID BIGINT not null,
MENTIONS_ID BIGINT not null,
);