Added a test-case to proofe, that @Converter and @Lob can be used together
authorKai Moritz <kai@juplo.de>
Sun, 13 Nov 2016 13:59:45 +0000 (14:59 +0100)
committerKai Moritz <kai@juplo.de>
Sun, 13 Nov 2016 16:37:15 +0000 (17:37 +0100)
See: https://hibernate.atlassian.net/browse/HHH-9615

src/it/lob/create.sql [new file with mode: 0644]
src/it/lob/pom.xml [new file with mode: 0644]
src/it/lob/src/main/java/de/juplo/tests/MyConverter.java [new file with mode: 0644]
src/it/lob/src/main/java/de/juplo/tests/MyEntity.java [new file with mode: 0644]
src/it/lob/verify.bsh [new file with mode: 0644]

diff --git a/src/it/lob/create.sql b/src/it/lob/create.sql
new file mode 100644 (file)
index 0000000..ed04fc4
--- /dev/null
@@ -0,0 +1,7 @@
+create sequence hibernate_sequence start with 1 increment by 1;
+
+    create table MyEntity (
+        id integer not null,
+        status blob,
+        primary key (id)
+    );
diff --git a/src/it/lob/pom.xml b/src/it/lob/pom.xml
new file mode 100644 (file)
index 0000000..bba73bc
--- /dev/null
@@ -0,0 +1,50 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>de.juplo.tests</groupId>
+  <artifactId>lob</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <name>lob</name>
+  <url>http://maven.apache.org</url>
+  <dependencies>
+    <dependency>
+      <groupId>org.hibernate</groupId>
+      <artifactId>hibernate-core</artifactId>
+      <version>5.2.4.Final</version>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.0.2</version>
+        <configuration>
+          <source>1.7</source>
+          <target>1.7</target>
+          <encoding>utf8</encoding>
+          <showWarnings>true</showWarnings>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>de.juplo</groupId>
+        <artifactId>hibernate-maven-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <dialect>org.hibernate.dialect.H2Dialect</dialect>
+          <execute>false</execute>
+          <format>true</format>
+        </configuration>
+        <executions>
+          <execution>
+            <id>create</id>
+            <goals>
+              <goal>create</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/lob/src/main/java/de/juplo/tests/MyConverter.java b/src/it/lob/src/main/java/de/juplo/tests/MyConverter.java
new file mode 100644 (file)
index 0000000..1c0e30b
--- /dev/null
@@ -0,0 +1,26 @@
+package de.juplo.tests;
+
+import javax.persistence.AttributeConverter;
+import javax.persistence.Converter;
+
+
+/**
+ * Taken from https://hibernate.atlassian.net/browse/HHH-9615
+ * @author Kai Moritz 
+ */
+@Converter
+public class MyConverter implements AttributeConverter<String, Integer>
+{
+
+  @Override
+  public Integer convertToDatabaseColumn(String attribute)
+  {
+    return attribute.length();
+  }
+
+  @Override
+  public String convertToEntityAttribute(Integer dbData)
+  {
+    return "";
+  }
+}
diff --git a/src/it/lob/src/main/java/de/juplo/tests/MyEntity.java b/src/it/lob/src/main/java/de/juplo/tests/MyEntity.java
new file mode 100644 (file)
index 0000000..e382150
--- /dev/null
@@ -0,0 +1,25 @@
+package de.juplo.tests;
+
+import javax.persistence.Convert;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+
+
+/**
+ * Taken from https://hibernate.atlassian.net/browse/HHH-9615
+ * @author Kai Moritz 
+ */
+@Entity
+public class MyEntity {
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    private Integer id;
+
+    @Convert(converter = MyConverter.class)
+    @Lob
+    private String status;
+
+}
diff --git a/src/it/lob/verify.bsh b/src/it/lob/verify.bsh
new file mode 100644 (file)
index 0000000..ce2e5a5
--- /dev/null
@@ -0,0 +1,7 @@
+import de.juplo.test.FileComparator;
+
+
+FileComparator comparator = new FileComparator(basedir);
+
+if (!comparator.isEqual("create.sql","target/create.sql"))
+  return false;