diff --git a/.gitignore b/.gitignore index 278c451..d79a52e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ bin # idea .idea/ *.iml + +**/.idea/ diff --git a/pom.xml b/pom.xml index e42c2b3..2ea4b53 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ 4.0.0 io.github.divinespear jpa-schema-maven-plugin - 0.2.2-SNAPSHOT + 0.2.2-jakarta-SNAPSHOT maven-plugin @@ -64,15 +64,15 @@ github UTF-8 - 1.7 - 1.7 + 17 + 17 3.3.1 - 3.4 - 2.6.1 - 5.0.7.Final - 4.2.3 - 1.11.23.RELEASE + 3.9.0 + 3.0.3 + 6.2.1.Final + 3.1.0 + 3.1.0 @@ -110,14 +110,12 @@ commons-lang 2.6 - - javax.xml.bind - jaxb-api - 2.3.0 + jakarta.xml.bind + jakarta.xml.bind-api + 4.0.0 provided - org.apache.maven.plugin-tools maven-plugin-tools-generators @@ -144,18 +142,11 @@ provided - org.hibernate - hibernate-entitymanager + org.hibernate.orm + hibernate-core ${hibernate.version} provided - - org.datanucleus - datanucleus-accessplatform-jpa-rdbms - ${datanucleus.version} - pom - provided - org.springframework.data spring-data-jpa @@ -175,9 +166,9 @@ - org.mockito + org.mockito mockito-core - 1.9.5 + 5.3.1 test @@ -210,8 +201,13 @@ [1.4, 1.9) test + + + jakarta.persistence + jakarta.persistence-api + ${jakarta.version} + - diff --git a/src/main/java/io/github/divinespear/maven/plugin/JpaSchemaGeneratorMojo.java b/src/main/java/io/github/divinespear/maven/plugin/JpaSchemaGeneratorMojo.java index 590a78e..e01d3fd 100644 --- a/src/main/java/io/github/divinespear/maven/plugin/JpaSchemaGeneratorMojo.java +++ b/src/main/java/io/github/divinespear/maven/plugin/JpaSchemaGeneratorMojo.java @@ -19,6 +19,8 @@ package io.github.divinespear.maven.plugin; +import jakarta.persistence.Persistence; +import jakarta.persistence.spi.PersistenceProvider; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; @@ -27,6 +29,7 @@ import java.lang.reflect.Field; import java.net.URL; import java.net.URLClassLoader; +import java.nio.file.Files; import java.sql.DatabaseMetaData; import java.sql.Driver; import java.sql.DriverManager; @@ -38,9 +41,6 @@ import java.util.Set; import java.util.regex.Pattern; -import javax.persistence.Persistence; -import javax.persistence.spi.PersistenceProvider; - import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; @@ -58,7 +58,6 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.util.StringUtils; import org.eclipse.persistence.config.PersistenceUnitProperties; -import org.hibernate.tool.hbm2ddl.SchemaExport; import org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager; import org.springframework.orm.jpa.persistenceunit.SmartPersistenceUnitInfo; @@ -500,6 +499,11 @@ private ClassLoader getProjectClassLoader() throws MojoExecutionException { } private void generate() throws Exception { + if (getOutputDirectory() != null) { + Files.deleteIfExists(getCreateOutputFile().toPath()); + Files.deleteIfExists(getDropOutputFile().toPath()); + } + Map map = JpaSchemaGeneratorUtils.buildProperties(this); if (getVendor() == null) { // with persistence.xml @@ -586,7 +590,7 @@ private void postProcess() throws IOException { continue; } s = s.trim(); - writer.print((this.isFormat() ? format(s) : s).replaceAll("\r\n", linesep)); + writer.print((this.isFormat() ? format(s) : s).replaceAll("\r?\n", linesep)); writer.print(";"); writer.print(linesep); writer.print(this.isFormat() ? linesep : ""); diff --git a/src/main/java/io/github/divinespear/maven/plugin/JpaSchemaGeneratorUtils.java b/src/main/java/io/github/divinespear/maven/plugin/JpaSchemaGeneratorUtils.java index f359c38..3eb07af 100644 --- a/src/main/java/io/github/divinespear/maven/plugin/JpaSchemaGeneratorUtils.java +++ b/src/main/java/io/github/divinespear/maven/plugin/JpaSchemaGeneratorUtils.java @@ -13,6 +13,8 @@ import org.hibernate.engine.jdbc.dialect.internal.StandardDialectResolver; import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo; +import static org.hibernate.cfg.AvailableSettings.JAKARTA_HBM2DDL_CONNECTION; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -128,6 +130,11 @@ public int getDriverMinorVersion() { return 0; } + @Override + public String getSQLKeywords() { + return "ABORT,DECIMAL,INTERVAL,PRESERVE,ALL,DECODE,INTO,PRIMARY,ALLOCATE,DEFAULT,LEADING,RESET,ANALYSE,DESC,LEFT,REUSE,ANALYZE,DISTINCT,LIKE,RIGHT,AND,DISTRIBUTE,LIMIT,ROWS,ANY,DO,LOAD,SELECT,AS,ELSE,LOCAL,SESSION_USER,ASC,END,LOCK,SETOF,BETWEEN,EXCEPT,MINUS,SHOW,BINARY,EXCLUDE,MOVE,SOME,BIT,EXISTS,NATURAL,TABLE,BOTH,EXPLAIN,NCHAR,THEN,CASE,EXPRESS,NEW,TIES,CAST,EXTEND,NOT,TIME,CHAR,EXTERNAL,NOTNULL,TIMESTAMP,CHARACTER,EXTRACT,NULL,TO,CHECK,FALSE,NULLS,TRAILING,CLUSTER,FIRST,NUMERIC,TRANSACTION,COALESCE,FLOAT,NVL,TRIGGER,COLLATE,FOLLOWING,NVL2,TRIM,COLLATION,FOR,OFF,TRUE,COLUMN,FOREIGN,OFFSET,UNBOUNDED,CONSTRAINT,FROM,OLD,UNION,COPY,FULL,ON,UNIQUE,CROSS,FUNCTION,ONLINE,USER,CURRENT,GENSTATS,ONLY,USING,CURRENT_CATALOG,GLOBAL,OR,VACUUM,CURRENT_DATE,GROUP,ORDER,VARCHAR,CURRENT_DB,HAVING,OTHERS,VERBOSE,CURRENT_SCHEMA,IDENTIFIER_CASE,OUT,VERSION,CURRENT_SID,ILIKE,OUTER,VIEW,CURRENT_TIME,IN,OVER,WHEN,CURRENT_TIMESTAMP,INDEX,OVERLAPS,WHERE,CURRENT_USER,INITIALLY,PARTITION,WITH,CURRENT_USERID,INNER,POSITION,WRITE,CURRENT_USEROID,INOUT,PRECEDING,RESET,DEALLOCATE,INTERSECT,PRECISION,REUSE,DEC"; + } + @Override public int getDriverMajorVersion() { return 0; @@ -138,6 +145,11 @@ public String getDatabaseName() { return productName; } + @Override + public String getDatabaseVersion() { + return String.format("%d.%d", getDatabaseMajorVersion(), getDatabaseMinorVersion()); + } + @Override public int getDatabaseMinorVersion() { return minorVersion; @@ -148,7 +160,7 @@ public int getDatabaseMajorVersion() { return majorVersion; } }; - Dialect detectedDialect = StandardDialectResolver.INSTANCE.resolveDialect(info); + Dialect detectedDialect = new StandardDialectResolver().resolveDialect(info); dialect = detectedDialect.getClass().getName(); } if (dialect != null) { @@ -157,7 +169,7 @@ public int getDatabaseMajorVersion() { } if (!isDatabaseTarget(mojo) && StringUtils.isEmpty(mojo.getJdbcUrl())) { - map.put(org.hibernate.jpa.AvailableSettings.SCHEMA_GEN_CONNECTION, + map.put(JAKARTA_HBM2DDL_CONNECTION, new ConnectionMock(mojo.getDatabaseProductName(), mojo.getDatabaseMajorVersion(), mojo.getDatabaseMinorVersion())); diff --git a/src/test/resources/unit/eclipselink-formatted-script-test/pom.xml b/src/test/resources/unit/eclipselink-formatted-script-test/pom.xml index 7ba4a98..06c7876 100644 --- a/src/test/resources/unit/eclipselink-formatted-script-test/pom.xml +++ b/src/test/resources/unit/eclipselink-formatted-script-test/pom.xml @@ -25,9 +25,9 @@ 0.0.0-TEST UTF-8 - 1.7 - 1.7 - 2.6.1 + 17 + 17 + 3.0.3 diff --git a/src/test/resources/unit/eclipselink-noxml-database-test/pom.xml b/src/test/resources/unit/eclipselink-noxml-database-test/pom.xml index d51d4b5..5f3a099 100644 --- a/src/test/resources/unit/eclipselink-noxml-database-test/pom.xml +++ b/src/test/resources/unit/eclipselink-noxml-database-test/pom.xml @@ -25,9 +25,9 @@ 0.0.0-TEST UTF-8 - 1.7 - 1.7 - 2.6.1 + 17 + 17 + 3.0.3 diff --git a/src/test/resources/unit/eclipselink-noxml-script-test/pom.xml b/src/test/resources/unit/eclipselink-noxml-script-test/pom.xml index 2955129..e19720a 100644 --- a/src/test/resources/unit/eclipselink-noxml-script-test/pom.xml +++ b/src/test/resources/unit/eclipselink-noxml-script-test/pom.xml @@ -25,9 +25,9 @@ 0.0.0-TEST UTF-8 - 1.7 - 1.7 - 2.6.1 + 17 + 17 + 3.0.3 diff --git a/src/test/resources/unit/eclipselink-simple-database-test/pom.xml b/src/test/resources/unit/eclipselink-simple-database-test/pom.xml index dd61738..7007e65 100644 --- a/src/test/resources/unit/eclipselink-simple-database-test/pom.xml +++ b/src/test/resources/unit/eclipselink-simple-database-test/pom.xml @@ -25,9 +25,9 @@ 0.0.0-TEST UTF-8 - 1.7 - 1.7 - 2.6.1 + 17 + 17 + 3.0.3 diff --git a/src/test/resources/unit/eclipselink-simple-script-test/pom.xml b/src/test/resources/unit/eclipselink-simple-script-test/pom.xml index 6107d2b..fff8330 100644 --- a/src/test/resources/unit/eclipselink-simple-script-test/pom.xml +++ b/src/test/resources/unit/eclipselink-simple-script-test/pom.xml @@ -25,9 +25,9 @@ 0.0.0-TEST UTF-8 - 1.7 - 1.7 - 2.6.1 + 17 + 17 + 3.0.3 diff --git a/src/test/resources/unit/hibernate-formatted-script-test/expected-create.txt b/src/test/resources/unit/hibernate-formatted-script-test/expected-create.txt index 3afec9a..e4bf8b6 100644 --- a/src/test/resources/unit/hibernate-formatted-script-test/expected-create.txt +++ b/src/test/resources/unit/hibernate-formatted-script-test/expected-create.txt @@ -1,8 +1,8 @@ -create sequence hibernate_sequence start with 1 increment by 1; +create sequence MANY_COLUMN_TABLE_SEQ start with 1 increment by 50; create table KEY_VALUE_STORE ( STORED_KEY varchar(128) not null, - CREATED_AT timestamp, + CREATED_AT timestamp(6), STORED_VALUE varchar(32768), primary key (STORED_KEY) ); diff --git a/src/test/resources/unit/hibernate-formatted-script-test/expected-drop.txt b/src/test/resources/unit/hibernate-formatted-script-test/expected-drop.txt index af3afe4..0cfa3f8 100644 --- a/src/test/resources/unit/hibernate-formatted-script-test/expected-drop.txt +++ b/src/test/resources/unit/hibernate-formatted-script-test/expected-drop.txt @@ -2,5 +2,5 @@ drop table KEY_VALUE_STORE if exists; drop table MANY_COLUMN_TABLE if exists; -drop sequence if exists hibernate_sequence; +drop sequence if exists MANY_COLUMN_TABLE_SEQ; diff --git a/src/test/resources/unit/hibernate-formatted-script-test/pom.xml b/src/test/resources/unit/hibernate-formatted-script-test/pom.xml index d38b684..ef7f5b0 100644 --- a/src/test/resources/unit/hibernate-formatted-script-test/pom.xml +++ b/src/test/resources/unit/hibernate-formatted-script-test/pom.xml @@ -25,14 +25,14 @@ 0.0.0-TEST UTF-8 - 1.7 - 1.7 - 5.0.7.Final + 17 + 17 + 6.2.1.Final - org.hibernate - hibernate-entitymanager + org.hibernate.orm + hibernate-core ${hibernate.version} diff --git a/src/test/resources/unit/hibernate-noxml-database-test/pom.xml b/src/test/resources/unit/hibernate-noxml-database-test/pom.xml index 9b3e45d..ade72cc 100644 --- a/src/test/resources/unit/hibernate-noxml-database-test/pom.xml +++ b/src/test/resources/unit/hibernate-noxml-database-test/pom.xml @@ -25,14 +25,14 @@ 0.0.0-TEST UTF-8 - 1.7 - 1.7 - 5.0.7.Final + 17 + 17 + 6.2.1.Final - org.hibernate - hibernate-entitymanager + org.hibernate.orm + hibernate-core ${hibernate.version} diff --git a/src/test/resources/unit/hibernate-noxml-script-test/expected-create.txt b/src/test/resources/unit/hibernate-noxml-script-test/expected-create.txt index 31b8135..8b92e1a 100644 --- a/src/test/resources/unit/hibernate-noxml-script-test/expected-create.txt +++ b/src/test/resources/unit/hibernate-noxml-script-test/expected-create.txt @@ -1,3 +1,3 @@ -create sequence hibernate_sequence start with 1 increment by 1; -create table KEY_VALUE_STORE (STORED_KEY varchar(128) not null, CREATED_AT timestamp, STORED_VALUE varchar(32768), primary key (STORED_KEY)); +create sequence MANY_COLUMN_TABLE_SEQ start with 1 increment by 50; +create table KEY_VALUE_STORE (STORED_KEY varchar(128) not null, CREATED_AT timestamp(6), STORED_VALUE varchar(32768), primary key (STORED_KEY)); create table MANY_COLUMN_TABLE (id bigint not null, column00 varchar(255), column01 varchar(255), column02 varchar(255), column03 varchar(255), column04 varchar(255), column05 varchar(255), column06 varchar(255), column07 varchar(255), column08 varchar(255), column09 varchar(255), column10 varchar(255), column11 varchar(255), column12 varchar(255), column13 varchar(255), column14 varchar(255), column15 varchar(255), column16 varchar(255), column17 varchar(255), column18 varchar(255), column19 varchar(255), column20 varchar(255), column21 varchar(255), column22 varchar(255), column23 varchar(255), column24 varchar(255), column25 varchar(255), column26 varchar(255), column27 varchar(255), column28 varchar(255), column29 varchar(255), primary key (id)); diff --git a/src/test/resources/unit/hibernate-noxml-script-test/expected-drop.txt b/src/test/resources/unit/hibernate-noxml-script-test/expected-drop.txt index 530c215..d39e62c 100644 --- a/src/test/resources/unit/hibernate-noxml-script-test/expected-drop.txt +++ b/src/test/resources/unit/hibernate-noxml-script-test/expected-drop.txt @@ -1,3 +1,3 @@ drop table KEY_VALUE_STORE if exists; drop table MANY_COLUMN_TABLE if exists; -drop sequence if exists hibernate_sequence; +drop sequence if exists MANY_COLUMN_TABLE_SEQ; diff --git a/src/test/resources/unit/hibernate-noxml-script-test/pom.xml b/src/test/resources/unit/hibernate-noxml-script-test/pom.xml index 65b8a54..f99d5a6 100644 --- a/src/test/resources/unit/hibernate-noxml-script-test/pom.xml +++ b/src/test/resources/unit/hibernate-noxml-script-test/pom.xml @@ -25,14 +25,14 @@ 0.0.0-TEST UTF-8 - 1.7 - 1.7 - 5.0.7.Final + 17 + 17 + 6.2.1.Final - org.hibernate - hibernate-entitymanager + org.hibernate.orm + hibernate-core ${hibernate.version} diff --git a/src/test/resources/unit/hibernate-simple-database-test/pom.xml b/src/test/resources/unit/hibernate-simple-database-test/pom.xml index 2dbf5f4..a030294 100644 --- a/src/test/resources/unit/hibernate-simple-database-test/pom.xml +++ b/src/test/resources/unit/hibernate-simple-database-test/pom.xml @@ -25,14 +25,14 @@ 0.0.0-TEST UTF-8 - 1.7 - 1.7 - 5.0.7.Final + 17 + 17 + 6.2.1.Final - org.hibernate - hibernate-entitymanager + org.hibernate.orm + hibernate-core ${hibernate.version} diff --git a/src/test/resources/unit/hibernate-simple-script-test/expected-create.txt b/src/test/resources/unit/hibernate-simple-script-test/expected-create.txt index 31b8135..8b92e1a 100644 --- a/src/test/resources/unit/hibernate-simple-script-test/expected-create.txt +++ b/src/test/resources/unit/hibernate-simple-script-test/expected-create.txt @@ -1,3 +1,3 @@ -create sequence hibernate_sequence start with 1 increment by 1; -create table KEY_VALUE_STORE (STORED_KEY varchar(128) not null, CREATED_AT timestamp, STORED_VALUE varchar(32768), primary key (STORED_KEY)); +create sequence MANY_COLUMN_TABLE_SEQ start with 1 increment by 50; +create table KEY_VALUE_STORE (STORED_KEY varchar(128) not null, CREATED_AT timestamp(6), STORED_VALUE varchar(32768), primary key (STORED_KEY)); create table MANY_COLUMN_TABLE (id bigint not null, column00 varchar(255), column01 varchar(255), column02 varchar(255), column03 varchar(255), column04 varchar(255), column05 varchar(255), column06 varchar(255), column07 varchar(255), column08 varchar(255), column09 varchar(255), column10 varchar(255), column11 varchar(255), column12 varchar(255), column13 varchar(255), column14 varchar(255), column15 varchar(255), column16 varchar(255), column17 varchar(255), column18 varchar(255), column19 varchar(255), column20 varchar(255), column21 varchar(255), column22 varchar(255), column23 varchar(255), column24 varchar(255), column25 varchar(255), column26 varchar(255), column27 varchar(255), column28 varchar(255), column29 varchar(255), primary key (id)); diff --git a/src/test/resources/unit/hibernate-simple-script-test/expected-drop.txt b/src/test/resources/unit/hibernate-simple-script-test/expected-drop.txt index 530c215..d39e62c 100644 --- a/src/test/resources/unit/hibernate-simple-script-test/expected-drop.txt +++ b/src/test/resources/unit/hibernate-simple-script-test/expected-drop.txt @@ -1,3 +1,3 @@ drop table KEY_VALUE_STORE if exists; drop table MANY_COLUMN_TABLE if exists; -drop sequence if exists hibernate_sequence; +drop sequence if exists MANY_COLUMN_TABLE_SEQ; diff --git a/src/test/resources/unit/hibernate-simple-script-test/pom.xml b/src/test/resources/unit/hibernate-simple-script-test/pom.xml index 7ae2d22..eee0400 100644 --- a/src/test/resources/unit/hibernate-simple-script-test/pom.xml +++ b/src/test/resources/unit/hibernate-simple-script-test/pom.xml @@ -25,14 +25,14 @@ 0.0.0-TEST UTF-8 - 1.7 - 1.7 - 5.0.7.Final + 17 + 17 + 6.2.1.Final - org.hibernate - hibernate-entitymanager + org.hibernate.orm + hibernate-core ${hibernate.version} diff --git a/src/test/resources/unit/issue-10/pom.xml b/src/test/resources/unit/issue-10/pom.xml index c61c221..1fbfa7b 100644 --- a/src/test/resources/unit/issue-10/pom.xml +++ b/src/test/resources/unit/issue-10/pom.xml @@ -25,14 +25,14 @@ 0.0.0-TEST UTF-8 - 1.7 - 1.7 - 5.0.7.Final + 17 + 17 + 6.2.1.Final - org.hibernate - hibernate-entitymanager + org.hibernate.orm + hibernate-core ${hibernate.version} diff --git a/src/test/resources/unit/issue-13/pom-crlf.xml b/src/test/resources/unit/issue-13/pom-crlf.xml index 7cebf1d..313b6ce 100644 --- a/src/test/resources/unit/issue-13/pom-crlf.xml +++ b/src/test/resources/unit/issue-13/pom-crlf.xml @@ -25,9 +25,9 @@ 0.0.0-TEST UTF-8 - 1.7 - 1.7 - 2.6.1 + 17 + 17 + 3.0.3 diff --git a/src/test/resources/unit/issue-13/pom-default.xml b/src/test/resources/unit/issue-13/pom-default.xml index 6c716dd..1ea4664 100644 --- a/src/test/resources/unit/issue-13/pom-default.xml +++ b/src/test/resources/unit/issue-13/pom-default.xml @@ -25,9 +25,9 @@ 0.0.0-TEST UTF-8 - 1.7 - 1.7 - 2.6.1 + 17 + 17 + 3.0.3 diff --git a/src/test/resources/unit/issue-17/pom.xml b/src/test/resources/unit/issue-17/pom.xml index 6c716dd..1ea4664 100644 --- a/src/test/resources/unit/issue-17/pom.xml +++ b/src/test/resources/unit/issue-17/pom.xml @@ -25,9 +25,9 @@ 0.0.0-TEST UTF-8 - 1.7 - 1.7 - 2.6.1 + 17 + 17 + 3.0.3 diff --git a/src/test/resources/unit/src/java/io/github/divinespear/model/KeyValueStore.java b/src/test/resources/unit/src/java/io/github/divinespear/model/KeyValueStore.java index 7cad606..ab2275d 100644 --- a/src/test/resources/unit/src/java/io/github/divinespear/model/KeyValueStore.java +++ b/src/test/resources/unit/src/java/io/github/divinespear/model/KeyValueStore.java @@ -21,14 +21,14 @@ import java.util.Date; -import javax.persistence.Access; -import javax.persistence.AccessType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; +import jakarta.persistence.Access; +import jakarta.persistence.AccessType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; /** * Test JPA model diff --git a/src/test/resources/unit/src/java/io/github/divinespear/model/ManyColumns.java b/src/test/resources/unit/src/java/io/github/divinespear/model/ManyColumns.java index 1e4466c..685d351 100644 --- a/src/test/resources/unit/src/java/io/github/divinespear/model/ManyColumns.java +++ b/src/test/resources/unit/src/java/io/github/divinespear/model/ManyColumns.java @@ -19,13 +19,12 @@ * under the License. */ -import javax.persistence.Access; -import javax.persistence.AccessType; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Access; +import jakarta.persistence.AccessType; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.Table; /** * Test JPA Model