From: Kai Moritz Date: Sun, 13 Nov 2016 14:26:18 +0000 (+0100) Subject: Added example-code for hibernate-bug HHH-9615 as additional test-case X-Git-Tag: hibernate-maven-plugin-2.1.0~11 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=c969993cb255167bf07632e03c1b2ecde72b2ebb;p=hibernate4-maven-plugin Added example-code for hibernate-bug HHH-9615 as additional test-case See: https://hibernate.atlassian.net/browse/HHH-9615 --- diff --git a/src/it/hibernate-lob-converter-bug/pom.xml b/src/it/hibernate-lob-converter-bug/pom.xml new file mode 100644 index 00000000..b2a76e75 --- /dev/null +++ b/src/it/hibernate-lob-converter-bug/pom.xml @@ -0,0 +1,44 @@ + + + 4.0.0 + + io.blep + hibernate-lob-converter-bug + 1.0-SNAPSHOT + + + jboss-maven2-release-repository + JBoss + https://repository.jboss.org/nexus/content/repositories/snapshots/ + + true + + + + + + + com.h2database + h2 + 1.3.168 + + + + junit + junit + 4.11 + test + + + org.hibernate + hibernate-entitymanager + 5.0.0-SNAPSHOT + + + + + + + \ No newline at end of file diff --git a/src/it/hibernate-lob-converter-bug/src/test/java/io/blep/LobConverterTest.java b/src/it/hibernate-lob-converter-bug/src/test/java/io/blep/LobConverterTest.java new file mode 100644 index 00000000..b08b8584 --- /dev/null +++ b/src/it/hibernate-lob-converter-bug/src/test/java/io/blep/LobConverterTest.java @@ -0,0 +1,22 @@ +package io.blep; + +import org.junit.Test; + +import javax.persistence.*; + +/** + * @author blep + */ +public class LobConverterTest { + + @Test + public void testName() throws Exception { + final EntityManagerFactory emf = Persistence.createEntityManagerFactory("samplePU"); + + final EntityManager em = emf.createEntityManager(); + + em.getTransaction().begin(); + em.persist(new MyEntity()); + em.getTransaction().commit(); + } +} diff --git a/src/it/hibernate-lob-converter-bug/src/test/java/io/blep/MyEntity.java b/src/it/hibernate-lob-converter-bug/src/test/java/io/blep/MyEntity.java new file mode 100644 index 00000000..0907809c --- /dev/null +++ b/src/it/hibernate-lob-converter-bug/src/test/java/io/blep/MyEntity.java @@ -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 { + + @Override + public Integer convertToDatabaseColumn(String attribute) { + return 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; + } + +} diff --git a/src/it/hibernate-lob-converter-bug/src/test/resources/META-INF/persistence.xml b/src/it/hibernate-lob-converter-bug/src/test/resources/META-INF/persistence.xml new file mode 100644 index 00000000..78e416df --- /dev/null +++ b/src/it/hibernate-lob-converter-bug/src/test/resources/META-INF/persistence.xml @@ -0,0 +1,14 @@ + + + + + org.hibernate.jpa.HibernatePersistenceProvider + io.blep.MyEntity + + + + + + + +