Fixed the akquisition of a database-connection, if one is needed
[hibernate4-maven-plugin] / src / it / hibernate-lob-converter-bug / src / main / java / io / blep / MyEntity.java
diff --git a/src/it/hibernate-lob-converter-bug/src/main/java/io/blep/MyEntity.java b/src/it/hibernate-lob-converter-bug/src/main/java/io/blep/MyEntity.java
new file mode 100644 (file)
index 0000000..e8bbd36
--- /dev/null
@@ -0,0 +1,48 @@
+package io.blep;
+
+import javax.persistence.*;
+
+/**
+ * @author blep
+ */
+@Entity
+public class MyEntity {
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    private Integer id;
+
+    @Convert(converter = MyConverter.class)
+    @Lob
+    private String status;
+
+    @Converter
+    public static class MyConverter implements AttributeConverter<String, Integer> {
+
+        @Override
+        public Integer convertToDatabaseColumn(String attribute) {
+            return attribute == null ? 0 : attribute.length();
+        }
+
+        @Override
+        public String convertToEntityAttribute(Integer dbData) {
+            return "";
+        }
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+}