mirror of
https://github.com/apache/openjpa.git
synced 2025-02-24 03:28:35 +00:00
OPENJPA-1034 Remove OrderColumn attributes and corresponding tests
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@764041 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
62aabafc53
commit
69d01f2813
@ -679,8 +679,6 @@ public abstract class MappingInfo
|
|||||||
boolean relationId = tmplate.isRelationId();
|
boolean relationId = tmplate.isRelationId();
|
||||||
boolean implicitRelation = tmplate.isImplicitRelation();
|
boolean implicitRelation = tmplate.isImplicitRelation();
|
||||||
String targetField = tmplate.getTargetField();
|
String targetField = tmplate.getTargetField();
|
||||||
int base = tmplate.getBase();
|
|
||||||
boolean contiguous = tmplate.isContiguous();
|
|
||||||
if (given != null) {
|
if (given != null) {
|
||||||
// use given type if provided, but warn if it isn't compatible with
|
// use given type if provided, but warn if it isn't compatible with
|
||||||
// the expected column type
|
// the expected column type
|
||||||
@ -699,8 +697,6 @@ public abstract class MappingInfo
|
|||||||
typeName = given.getTypeName();
|
typeName = given.getTypeName();
|
||||||
size = given.getSize();
|
size = given.getSize();
|
||||||
decimals = given.getDecimalDigits();
|
decimals = given.getDecimalDigits();
|
||||||
base = given.getBase();
|
|
||||||
contiguous = given.isContiguous();
|
|
||||||
|
|
||||||
// leave this info as the template defaults unless the user
|
// leave this info as the template defaults unless the user
|
||||||
// explicitly turns it on in the given column
|
// explicitly turns it on in the given column
|
||||||
@ -760,8 +756,6 @@ public abstract class MappingInfo
|
|||||||
col.setRelationId(relationId);
|
col.setRelationId(relationId);
|
||||||
col.setImplicitRelation(implicitRelation);
|
col.setImplicitRelation(implicitRelation);
|
||||||
col.setTargetField(targetField);
|
col.setTargetField(targetField);
|
||||||
col.setContiguous(contiguous);
|
|
||||||
col.setBase(base);
|
|
||||||
|
|
||||||
// we need this for runtime, and the dynamic schema factory might
|
// we need this for runtime, and the dynamic schema factory might
|
||||||
// not know it, so set it even if not adapting
|
// not know it, so set it even if not adapting
|
||||||
|
@ -149,7 +149,7 @@ public class HandlerCollectionTableFieldStrategy
|
|||||||
ValueMapping elem = field.getElementMapping();
|
ValueMapping elem = field.getElementMapping();
|
||||||
Column order = field.getOrderColumn();
|
Column order = field.getOrderColumn();
|
||||||
boolean setOrder = field.getOrderColumnIO().isInsertable(order, false);
|
boolean setOrder = field.getOrderColumnIO().isInsertable(order, false);
|
||||||
int idx = (setOrder && order != null) ? order.getBase() : 0;
|
int idx = 0;
|
||||||
for (Iterator itr = coll.iterator(); itr.hasNext(); idx++) {
|
for (Iterator itr = coll.iterator(); itr.hasNext(); idx++) {
|
||||||
HandlerStrategies.set(elem, itr.next(), store, row, _cols,
|
HandlerStrategies.set(elem, itr.next(), store, row, _cols,
|
||||||
_io, true);
|
_io, true);
|
||||||
|
@ -162,7 +162,7 @@ public abstract class RelationToManyTableFieldStrategy
|
|||||||
StoreContext ctx = sm.getContext();
|
StoreContext ctx = sm.getContext();
|
||||||
Column order = field.getOrderColumn();
|
Column order = field.getOrderColumn();
|
||||||
boolean setOrder = field.getOrderColumnIO().isInsertable(order, false);
|
boolean setOrder = field.getOrderColumnIO().isInsertable(order, false);
|
||||||
int idx = (setOrder && order != null) ? order.getBase() : 0;
|
int idx = 0;
|
||||||
OpenJPAStateManager esm;
|
OpenJPAStateManager esm;
|
||||||
for (Iterator itr = coll.iterator(); itr.hasNext(); idx++) {
|
for (Iterator itr = coll.iterator(); itr.hasNext(); idx++) {
|
||||||
esm = RelationStrategies.getStateManager(itr.next(), ctx);
|
esm = RelationStrategies.getStateManager(itr.next(), ctx);
|
||||||
|
@ -76,9 +76,6 @@ public class Column
|
|||||||
private String _comment = null;
|
private String _comment = null;
|
||||||
private boolean _XML = false;
|
private boolean _XML = false;
|
||||||
|
|
||||||
private boolean _contiguous = true;
|
|
||||||
private int _base = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
*/
|
*/
|
||||||
@ -727,10 +724,6 @@ public class Column
|
|||||||
_flags = from._flags;
|
_flags = from._flags;
|
||||||
if (!isXML())
|
if (!isXML())
|
||||||
setXML(from.isXML());
|
setXML(from.isXML());
|
||||||
if (getBase() == 0)
|
|
||||||
setBase(from.getBase());
|
|
||||||
if (isContiguous())
|
|
||||||
setContiguous(from.isContiguous());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -790,40 +783,4 @@ public class Column
|
|||||||
public void setImplicitRelation(boolean flag) {
|
public void setImplicitRelation(boolean flag) {
|
||||||
_implicitRelation |= flag;
|
_implicitRelation |= flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets whether the column values should be contiguous for a column
|
|
||||||
* purposed as an order column
|
|
||||||
*
|
|
||||||
* @param contiguous
|
|
||||||
*/
|
|
||||||
public void setContiguous(boolean contiguous) {
|
|
||||||
_contiguous = contiguous;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets whether the column values should be contiguous for a column
|
|
||||||
* purposed as an order column
|
|
||||||
*
|
|
||||||
* @param contiguous
|
|
||||||
*/
|
|
||||||
public boolean isContiguous() {
|
|
||||||
return _contiguous;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the base value for a column purposed as an order column
|
|
||||||
* @param base integral base value to begin ordering
|
|
||||||
*/
|
|
||||||
public void setBase(int base) {
|
|
||||||
_base = base;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the base value for a column purposed as an order column
|
|
||||||
* @param base
|
|
||||||
*/
|
|
||||||
public int getBase() {
|
|
||||||
return _base;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1148,14 +1148,6 @@ public class XMLPersistenceMappingParser
|
|||||||
if (val != null)
|
if (val != null)
|
||||||
col.setFlag(Column.FLAG_UNUPDATABLE, "false".equals(val));
|
col.setFlag(Column.FLAG_UNUPDATABLE, "false".equals(val));
|
||||||
|
|
||||||
val = attrs.getValue("base");
|
|
||||||
if (val != null)
|
|
||||||
col.setBase(Integer.parseInt(val));
|
|
||||||
|
|
||||||
val = attrs.getValue("contiguous");
|
|
||||||
if (val != null)
|
|
||||||
col.setContiguous("false".equals(val));
|
|
||||||
|
|
||||||
val = attrs.getValue("table");
|
val = attrs.getValue("table");
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
col.setTableName(val);
|
col.setTableName(val);
|
||||||
|
@ -457,10 +457,6 @@ public class XMLPersistenceMappingSerializer
|
|||||||
addAttribute("updatable", "false");
|
addAttribute("updatable", "false");
|
||||||
if (orderCol.getTypeName() != null)
|
if (orderCol.getTypeName() != null)
|
||||||
addAttribute("column-definition", orderCol.getTypeName());
|
addAttribute("column-definition", orderCol.getTypeName());
|
||||||
if (orderCol.isContiguous() != true)
|
|
||||||
addAttribute("contiguous", "false");
|
|
||||||
if (orderCol.getBase() != 0)
|
|
||||||
addAttribute("base", orderCol.getBase() + "");
|
|
||||||
if (orderCol.getTableName() != null)
|
if (orderCol.getTableName() != null)
|
||||||
addAttribute("table", orderCol.getTableName());
|
addAttribute("table", orderCol.getTableName());
|
||||||
startElement("order-column");
|
startElement("order-column");
|
||||||
|
@ -520,84 +520,6 @@ public class TestOrderColumn extends SingleEMFTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Validates the default base value on OrderColumn
|
|
||||||
*/
|
|
||||||
public void testOrderColumnBase() {
|
|
||||||
|
|
||||||
OpenJPAEntityManagerFactorySPI emf1 =
|
|
||||||
(OpenJPAEntityManagerFactorySPI)OpenJPAPersistence.
|
|
||||||
createEntityManagerFactory("BaseTest",
|
|
||||||
"org/apache/openjpa/persistence/jdbc/order/" +
|
|
||||||
"order-persistence.xml");
|
|
||||||
|
|
||||||
// Verify order column names are as expected
|
|
||||||
validateOrderColumnName(emf1, BaseTestEntity.class, "collelems",
|
|
||||||
"collelems_ORDER");
|
|
||||||
|
|
||||||
validateOrderColumnName(emf1, BaseTestEntity.class, "one2Melems",
|
|
||||||
"one2MOrder");
|
|
||||||
|
|
||||||
validateOrderColumnName(emf1, BaseTestEntity.class, "m2melems",
|
|
||||||
"m2morder");
|
|
||||||
|
|
||||||
OpenJPAEntityManagerSPI em = emf1.createEntityManager();
|
|
||||||
|
|
||||||
// Create a collection with a non-default base value
|
|
||||||
BaseTestEntity bte = new BaseTestEntity();
|
|
||||||
BaseTestElement[] elems = new BaseTestElement[9];
|
|
||||||
for (int i = 0; i < 9; i++) {
|
|
||||||
int elemnum = (i % 3 ) + 1;
|
|
||||||
elems[i] = new BaseTestElement("Element " + elemnum);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add to element collection with base value 0
|
|
||||||
Set<BaseTestElement> elemset = new LinkedHashSet<BaseTestElement>();
|
|
||||||
for (int i = 0; i < 3; i++)
|
|
||||||
elemset.add(elems[i]);
|
|
||||||
bte.setCollelems(elemset);
|
|
||||||
|
|
||||||
// Add to OneToMany with base value 0
|
|
||||||
List<BaseTestElement> elemList = new ArrayList<BaseTestElement>();
|
|
||||||
for (int i = 0; i < 3; i++)
|
|
||||||
elemList.add(elems[i + 3]);
|
|
||||||
bte.setOne2Melems(elemList);
|
|
||||||
|
|
||||||
// Add to ManyToMany, base value 0
|
|
||||||
List<BaseTestElement> elemList2 = new ArrayList<BaseTestElement>();
|
|
||||||
for (int i = 0; i < 3; i++)
|
|
||||||
elemList2.add(elems[i + 6]);
|
|
||||||
bte.setM2melems(elemList2);
|
|
||||||
|
|
||||||
em.getTransaction().begin();
|
|
||||||
em.persist(bte);
|
|
||||||
em.getTransaction().commit();
|
|
||||||
|
|
||||||
// Do a projection query to verify the base values
|
|
||||||
|
|
||||||
validateIndexAndValues(em, "BaseTestEntity", "one2Melems", 0,
|
|
||||||
new Object[] { elems[3], elems[4], elems[5]}, "id",
|
|
||||||
bte.getId());
|
|
||||||
|
|
||||||
validateIndexAndValues(em, "BaseTestEntity", "m2melems", 0,
|
|
||||||
new Object[] { elems[6], elems[7], elems[8]}, "id",
|
|
||||||
bte.getId());
|
|
||||||
|
|
||||||
// This validator is disabled until INDEX projection supports element
|
|
||||||
// collections
|
|
||||||
// validateIndexAndValues(em, "BaseTestEntity", "collelems", 0,
|
|
||||||
// new Object[] { elems[0], elems[1], elems[2]} "id",
|
|
||||||
// bte.getId());
|
|
||||||
|
|
||||||
em.close();
|
|
||||||
try {
|
|
||||||
if (emf1 != null)
|
|
||||||
cleanupEMF(emf1);
|
|
||||||
} catch (Exception e) {
|
|
||||||
fail(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Validates the use of the table attribute on OrderColumn with
|
* Validates the use of the table attribute on OrderColumn with
|
||||||
* o2o, o2m, m2m, and collection table - with and without join
|
* o2o, o2m, m2m, and collection table - with and without join
|
||||||
@ -671,11 +593,9 @@ public class TestOrderColumn extends SingleEMFTestCase {
|
|||||||
widgetArr, "id",
|
widgetArr, "id",
|
||||||
oid);
|
oid);
|
||||||
|
|
||||||
// This validator is disabled until INDEX projection supports element
|
validateIndexAndValues(em, "Owner", "bikeColl", 0,
|
||||||
// collections
|
bikeArr, "id",
|
||||||
// validateIndexAndValues(em, "Owner", "bikeColl", 0,
|
oid);
|
||||||
// bikeArr, "id",
|
|
||||||
// oid);
|
|
||||||
|
|
||||||
em.close();
|
em.close();
|
||||||
}
|
}
|
||||||
@ -857,19 +777,16 @@ public class TestOrderColumn extends SingleEMFTestCase {
|
|||||||
Column oc = fm.getOrderColumn();
|
Column oc = fm.getOrderColumn();
|
||||||
assertNotNull(oc);
|
assertNotNull(oc);
|
||||||
assertEquals(oc.getName(),"one2MOrder");
|
assertEquals(oc.getName(),"one2MOrder");
|
||||||
assertEquals(oc.getBase(), 0);
|
|
||||||
|
|
||||||
fm = (FieldMapping)_entityMeta2.getField("m2melems");
|
fm = (FieldMapping)_entityMeta2.getField("m2melems");
|
||||||
oc = fm.getOrderColumn();
|
oc = fm.getOrderColumn();
|
||||||
assertNotNull(oc);
|
assertNotNull(oc);
|
||||||
assertEquals(oc.getName(),"m2morder");
|
assertEquals(oc.getName(),"m2morder");
|
||||||
assertEquals(oc.getBase(), 0);
|
|
||||||
|
|
||||||
fm = (FieldMapping)_entityMeta2.getField("collelems");
|
fm = (FieldMapping)_entityMeta2.getField("collelems");
|
||||||
oc = fm.getOrderColumn();
|
oc = fm.getOrderColumn();
|
||||||
assertNotNull(oc);
|
assertNotNull(oc);
|
||||||
assertEquals(oc.getName(),"collelems_ORDER");
|
assertEquals(oc.getName(),"collelems_ORDER");
|
||||||
assertEquals(oc.getBase(), 0);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (emf1 != null)
|
if (emf1 != null)
|
||||||
@ -979,13 +896,6 @@ public class TestOrderColumn extends SingleEMFTestCase {
|
|||||||
columnName));
|
columnName));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateOrderColumnContiguous(
|
|
||||||
OpenJPAEntityManagerFactorySPI emf1, Class clazz, String fieldName,
|
|
||||||
boolean contiguous) {
|
|
||||||
Column oc = getOrderColumn(emf1, clazz, fieldName);
|
|
||||||
assertTrue(oc.isContiguous() == contiguous);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateOrderColumnDef(
|
private void validateOrderColumnDef(
|
||||||
OpenJPAEntityManagerFactorySPI emf1, Class clazz, String fieldName,
|
OpenJPAEntityManagerFactorySPI emf1, Class clazz, String fieldName,
|
||||||
String type) {
|
String type) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user