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) {
|
if (_cols != null) {
|
||||||
switch (fm.getDeclaredTypeCode()) {
|
switch (fm.getDeclaredTypeCode()) {
|
||||||
case JavaTypes.ARRAY:
|
case JavaTypes.ARRAY:
|
||||||
if (fm.getDeclaredType() == byte[].class
|
Class type = fm.getDeclaredType();
|
||||||
|| fm.getDeclaredType() == char[].class
|
if (type == byte[].class || type == Byte[].class
|
||||||
|| fm.getDeclaredType() == Character[].class) {
|
|| type == char[].class || type == Character[].class ) {
|
||||||
fm.getValueInfo().setColumns(_cols);
|
fm.getValueInfo().setColumns(_cols);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,10 +144,4 @@ public class TestDiscriminatorTypes extends SingleEMFTestCase {
|
||||||
assertNotNull(root2);
|
assertNotNull(root2);
|
||||||
em.close();
|
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;
|
package org.apache.openjpa.persistence.test;
|
||||||
|
|
||||||
|
import org.apache.openjpa.jdbc.meta.ClassMapping;
|
||||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
|
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
|
||||||
|
|
||||||
public abstract class SingleEMFTestCase
|
public abstract class SingleEMFTestCase
|
||||||
|
@ -61,4 +62,10 @@ public abstract class SingleEMFTestCase
|
||||||
closeEMF(emf);
|
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 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.InvalidStateException;
|
||||||
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
|
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
|
||||||
|
|
||||||
|
@ -62,6 +65,24 @@ public class TestXmlOverrideEntity extends SingleEMFTestCase {
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
em.remove(em.find(XmlOverrideEntity.class, optional.getId()));
|
em.remove(em.find(XmlOverrideEntity.class, optional.getId()));
|
||||||
em.getTransaction().commit();
|
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;
|
package org.apache.openjpa.persistence.xml;
|
||||||
|
|
||||||
import javax.persistence.Basic;
|
import javax.persistence.Basic;
|
||||||
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Lob;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class XmlOverrideEntity {
|
public class XmlOverrideEntity {
|
||||||
|
@ -36,6 +38,10 @@ public class XmlOverrideEntity {
|
||||||
@Basic(optional=true)
|
@Basic(optional=true)
|
||||||
String description;
|
String description;
|
||||||
|
|
||||||
|
@Column(name="PICTURE")
|
||||||
|
@Lob
|
||||||
|
private Byte[] picture;
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -59,5 +65,13 @@ public class XmlOverrideEntity {
|
||||||
public void setDescription(String description) {
|
public void setDescription(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Byte[] getPicture() {
|
||||||
|
return picture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPicture(Byte[] picture) {
|
||||||
|
this.picture = picture;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,10 @@
|
||||||
<attributes>
|
<attributes>
|
||||||
<basic name="name" optional="true"></basic>
|
<basic name="name" optional="true"></basic>
|
||||||
<basic name="description" optional="false"></basic>
|
<basic name="description" optional="false"></basic>
|
||||||
|
<basic name="picture" fetch="EAGER">
|
||||||
|
<column name="pic_xml"/>
|
||||||
|
<lob/>
|
||||||
|
</basic>
|
||||||
</attributes>
|
</attributes>
|
||||||
</entity>
|
</entity>
|
||||||
<entity name="AllFieldTypes"
|
<entity name="AllFieldTypes"
|
||||||
|
|
Loading…
Reference in New Issue