From: Kai Moritz Date: Mon, 27 Oct 2014 08:04:48 +0000 (+0100) Subject: Fixed NullPointerException, when dialect is specified in properties-file X-Git-Tag: hibernate4-maven-plugin-1.0.5~5 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=74c0dd783b84c90e116f3e7f1c8d6109845ba71f;p=hibernate4-maven-plugin Fixed NullPointerException, when dialect is specified in properties-file Also added an integration test-case, that proofed, that the error was solved. --- diff --git a/src/it/properties/h2.sql b/src/it/properties/h2.sql new file mode 100644 index 00000000..9569fa60 --- /dev/null +++ b/src/it/properties/h2.sql @@ -0,0 +1,12 @@ + + drop table test_simple if exists; + + create table test_simple ( + uuid varchar(36) not null, + content clob, + externalid varchar(148), + sources varchar(255), + primary key (uuid) + ); + + create index idx_test_simple_tuple on test_simple (sources, uuid); diff --git a/src/it/properties/pom.xml b/src/it/properties/pom.xml new file mode 100644 index 00000000..f3a6fc73 --- /dev/null +++ b/src/it/properties/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + de.juplo + hibernate4-properties-test + Hibernate 4 Test - Dialect in properties-file + 0.1-SNAPSHOT + jar + + + + + + org.hibernate + hibernate-core + 4.3.0.Final + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + 1.7 + 1.7 + utf8 + true + + + + + de.juplo + hibernate4-maven-plugin + @project.version@ + + + none + + both + + + + + export + + + + + + + diff --git a/src/it/properties/src/main/java/de/juplo/plugins/hibernate4/tests/SimplestMavenHib4Test.java b/src/it/properties/src/main/java/de/juplo/plugins/hibernate4/tests/SimplestMavenHib4Test.java new file mode 100644 index 00000000..3a3f565b --- /dev/null +++ b/src/it/properties/src/main/java/de/juplo/plugins/hibernate4/tests/SimplestMavenHib4Test.java @@ -0,0 +1,32 @@ +package de.juplo.plugins.hibernate4.tests; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Lob; +import javax.persistence.Table; + +import org.hibernate.annotations.Index; + +@Entity +@Table(name = "test_simple") +@org.hibernate.annotations.Table( + appliesTo="test_simple", + indexes = { + @Index(name="idx_test_simple_tuple", columnNames={"sources", "uuid"} ), + } +) +public class SimplestMavenHib4Test { + + private String sources; + + @Lob + private String content; + + @Id + @Column (length=36) + private String uuid; + + @Column(name = "externalid", length=148) + private String externalXyzId; +} diff --git a/src/it/properties/src/main/resources/hibernate.properties b/src/it/properties/src/main/resources/hibernate.properties new file mode 100644 index 00000000..0db87124 --- /dev/null +++ b/src/it/properties/src/main/resources/hibernate.properties @@ -0,0 +1 @@ +hibernate.dialect=org.hibernate.dialect.H2Dialect diff --git a/src/it/properties/verify.bsh b/src/it/properties/verify.bsh new file mode 100644 index 00000000..0dfcefe5 --- /dev/null +++ b/src/it/properties/verify.bsh @@ -0,0 +1,7 @@ +import de.juplo.test.FileComparator; + + +FileComparator comparator = new FileComparator(basedir); + +if (!comparator.isEqual("h2.sql","target/schema.sql")) + return false; diff --git a/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java b/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java index 73f0ab06..fa4ce6a0 100644 --- a/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java +++ b/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java @@ -598,6 +598,10 @@ public class Hbm2DdlMojo extends AbstractMojo ); properties.setProperty(DIALECT, hibernateDialect); } + else + { + hibernateDialect = properties.getProperty(DIALECT); + } if ( hibernateNamingStrategy != null ) { if ( properties.contains(NAMING_STRATEGY))