mirror of
https://github.com/apache/openjpa.git
synced 2025-02-23 19:05:00 +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 implicitRelation = tmplate.isImplicitRelation();
|
||||
String targetField = tmplate.getTargetField();
|
||||
int base = tmplate.getBase();
|
||||
boolean contiguous = tmplate.isContiguous();
|
||||
if (given != null) {
|
||||
// use given type if provided, but warn if it isn't compatible with
|
||||
// the expected column type
|
||||
@ -699,8 +697,6 @@ public abstract class MappingInfo
|
||||
typeName = given.getTypeName();
|
||||
size = given.getSize();
|
||||
decimals = given.getDecimalDigits();
|
||||
base = given.getBase();
|
||||
contiguous = given.isContiguous();
|
||||
|
||||
// leave this info as the template defaults unless the user
|
||||
// explicitly turns it on in the given column
|
||||
@ -760,8 +756,6 @@ public abstract class MappingInfo
|
||||
col.setRelationId(relationId);
|
||||
col.setImplicitRelation(implicitRelation);
|
||||
col.setTargetField(targetField);
|
||||
col.setContiguous(contiguous);
|
||||
col.setBase(base);
|
||||
|
||||
// we need this for runtime, and the dynamic schema factory might
|
||||
// not know it, so set it even if not adapting
|
||||
|
@ -149,7 +149,7 @@ public class HandlerCollectionTableFieldStrategy
|
||||
ValueMapping elem = field.getElementMapping();
|
||||
Column order = field.getOrderColumn();
|
||||
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++) {
|
||||
HandlerStrategies.set(elem, itr.next(), store, row, _cols,
|
||||
_io, true);
|
||||
|
@ -162,7 +162,7 @@ public abstract class RelationToManyTableFieldStrategy
|
||||
StoreContext ctx = sm.getContext();
|
||||
Column order = field.getOrderColumn();
|
||||
boolean setOrder = field.getOrderColumnIO().isInsertable(order, false);
|
||||
int idx = (setOrder && order != null) ? order.getBase() : 0;
|
||||
int idx = 0;
|
||||
OpenJPAStateManager esm;
|
||||
for (Iterator itr = coll.iterator(); itr.hasNext(); idx++) {
|
||||
esm = RelationStrategies.getStateManager(itr.next(), ctx);
|
||||
|
@ -75,9 +75,6 @@ public class Column
|
||||
private VersionStrategy _versionStrategy = null;
|
||||
private String _comment = null;
|
||||
private boolean _XML = false;
|
||||
|
||||
private boolean _contiguous = true;
|
||||
private int _base = 0;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
@ -727,10 +724,6 @@ public class Column
|
||||
_flags = from._flags;
|
||||
if (!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) {
|
||||
_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;
|
||||
}
|
||||
}
|
||||
|
@ -1147,14 +1147,6 @@ public class XMLPersistenceMappingParser
|
||||
val = attrs.getValue("updatable");
|
||||
if (val != null)
|
||||
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");
|
||||
if (val != null) {
|
||||
|
@ -457,10 +457,6 @@ public class XMLPersistenceMappingSerializer
|
||||
addAttribute("updatable", "false");
|
||||
if (orderCol.getTypeName() != null)
|
||||
addAttribute("column-definition", orderCol.getTypeName());
|
||||
if (orderCol.isContiguous() != true)
|
||||
addAttribute("contiguous", "false");
|
||||
if (orderCol.getBase() != 0)
|
||||
addAttribute("base", orderCol.getBase() + "");
|
||||
if (orderCol.getTableName() != null)
|
||||
addAttribute("table", orderCol.getTableName());
|
||||
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
|
||||
* o2o, o2m, m2m, and collection table - with and without join
|
||||
@ -671,11 +593,9 @@ public class TestOrderColumn extends SingleEMFTestCase {
|
||||
widgetArr, "id",
|
||||
oid);
|
||||
|
||||
// This validator is disabled until INDEX projection supports element
|
||||
// collections
|
||||
// validateIndexAndValues(em, "Owner", "bikeColl", 0,
|
||||
// bikeArr, "id",
|
||||
// oid);
|
||||
validateIndexAndValues(em, "Owner", "bikeColl", 0,
|
||||
bikeArr, "id",
|
||||
oid);
|
||||
|
||||
em.close();
|
||||
}
|
||||
@ -857,19 +777,16 @@ public class TestOrderColumn extends SingleEMFTestCase {
|
||||
Column oc = fm.getOrderColumn();
|
||||
assertNotNull(oc);
|
||||
assertEquals(oc.getName(),"one2MOrder");
|
||||
assertEquals(oc.getBase(), 0);
|
||||
|
||||
fm = (FieldMapping)_entityMeta2.getField("m2melems");
|
||||
oc = fm.getOrderColumn();
|
||||
assertNotNull(oc);
|
||||
assertEquals(oc.getName(),"m2morder");
|
||||
assertEquals(oc.getBase(), 0);
|
||||
|
||||
fm = (FieldMapping)_entityMeta2.getField("collelems");
|
||||
oc = fm.getOrderColumn();
|
||||
assertNotNull(oc);
|
||||
assertEquals(oc.getName(),"collelems_ORDER");
|
||||
assertEquals(oc.getBase(), 0);
|
||||
|
||||
try {
|
||||
if (emf1 != null)
|
||||
@ -977,13 +894,6 @@ public class TestOrderColumn extends SingleEMFTestCase {
|
||||
// Verify the table exists in the db
|
||||
assertTrue(tableAndColumnExists(emf1, null, tableName, null,
|
||||
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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user