diff --git a/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java b/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java index daed50ccb..c483d2834 100644 --- a/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java +++ b/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java @@ -541,9 +541,9 @@ public class XMLPersistenceMappingParser if (_cols != null) { switch (fm.getDeclaredTypeCode()) { case JavaTypes.ARRAY: - if (fm.getDeclaredType() == byte[].class - || fm.getDeclaredType() == char[].class - || fm.getDeclaredType() == Character[].class) { + Class type = fm.getDeclaredType(); + if (type == byte[].class || type == Byte[].class + || type == char[].class || type == Character[].class ) { fm.getValueInfo().setColumns(_cols); break; } diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java index 5c6f9863b..42a6e975a 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java @@ -144,10 +144,4 @@ public class TestDiscriminatorTypes extends SingleEMFTestCase { assertNotNull(root2); em.close(); } - - private ClassMapping getMapping(String name) { - return (ClassMapping) emf.getConfiguration() - .getMetaDataRepositoryInstance().getMetaData(name, - getClass().getClassLoader(), true); - } } diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMFTestCase.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMFTestCase.java index dd696592c..c27c7f511 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMFTestCase.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMFTestCase.java @@ -18,6 +18,7 @@ */ package org.apache.openjpa.persistence.test; +import org.apache.openjpa.jdbc.meta.ClassMapping; import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI; public abstract class SingleEMFTestCase @@ -61,4 +62,10 @@ public abstract class SingleEMFTestCase closeEMF(emf); } } + + protected ClassMapping getMapping(String name) { + return (ClassMapping) emf.getConfiguration() + .getMetaDataRepositoryInstance().getMetaData(name, + getClass().getClassLoader(), true); + } } diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestXmlOverrideEntity.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestXmlOverrideEntity.java index bed8b5dbe..b49191214 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestXmlOverrideEntity.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestXmlOverrideEntity.java @@ -20,6 +20,9 @@ package org.apache.openjpa.persistence.xml; import javax.persistence.EntityManager; +import org.apache.openjpa.jdbc.meta.ClassMapping; +import org.apache.openjpa.jdbc.meta.FieldMapping; +import org.apache.openjpa.jdbc.schema.Column; import org.apache.openjpa.persistence.InvalidStateException; import org.apache.openjpa.persistence.test.SingleEMFTestCase; @@ -62,6 +65,24 @@ public class TestXmlOverrideEntity extends SingleEMFTestCase { em.getTransaction().begin(); em.remove(em.find(XmlOverrideEntity.class, optional.getId())); em.getTransaction().commit(); + + em.close(); + } + + + public void testColumnOverride() { + EntityManager em = emf.createEntityManager(); + + ClassMapping mapping = getMapping("XmlOverride"); + + FieldMapping fm = mapping.getFieldMapping("picture"); + + Column[] columns = fm.getColumns(); + + assertEquals(1, columns.length); + assertEquals("pic_xml", columns[0].getName()); + + em.close(); } } diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/XmlOverrideEntity.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/XmlOverrideEntity.java index f7110a92f..5853e9a2e 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/XmlOverrideEntity.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/XmlOverrideEntity.java @@ -19,9 +19,11 @@ package org.apache.openjpa.persistence.xml; import javax.persistence.Basic; +import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; +import javax.persistence.Lob; @Entity public class XmlOverrideEntity { @@ -35,6 +37,10 @@ public class XmlOverrideEntity { @Basic(optional=true) String description; + + @Column(name="PICTURE") + @Lob + private Byte[] picture; public int getId() { return id; @@ -58,6 +64,14 @@ public class XmlOverrideEntity { public void setDescription(String description) { this.description = description; + } + + public Byte[] getPicture() { + return picture; + } + + public void setPicture(Byte[] picture) { + this.picture = picture; } } diff --git a/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/xml/orm.xml b/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/xml/orm.xml index 962b1c5ea..76dc33213 100644 --- a/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/xml/orm.xml +++ b/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/xml/orm.xml @@ -43,6 +43,10 @@ + + + +