mirror of https://github.com/apache/openjpa.git
OPENJPA-382
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@578867 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
89b030c3d1
commit
12840cafbf
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,10 @@
|
|||
<attributes>
|
||||
<basic name="name" optional="true"></basic>
|
||||
<basic name="description" optional="false"></basic>
|
||||
<basic name="picture" fetch="EAGER">
|
||||
<column name="pic_xml"/>
|
||||
<lob/>
|
||||
</basic>
|
||||
</attributes>
|
||||
</entity>
|
||||
<entity name="AllFieldTypes"
|
||||
|
|
Loading…
Reference in New Issue