You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by jr...@apache.org on 2009/01/23 05:54:34 UTC
svn commit: r736915 [1/2] - in /openjpa/trunk:
openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/
openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/
openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/
openjpa-kernel/src/main/j...
Author: jrbauer
Date: Thu Jan 22 20:54:33 2009
New Revision: 736915
URL: http://svn.apache.org/viewvc?rev=736915&view=rev
Log:
OPENJPA-802 Base OrderColumn support and corresponding tests
Added:
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/BaseTestElement.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/BaseTestEntity.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/BattingOrder.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/ColDefTestElement.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/ColDefTestEntity.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Course.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Game.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Inning.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/ObOcEntity.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Person.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Player.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Student.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/TestOrderColumn.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Trainer.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/order/
openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/order/order-orm-2.xml (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/order/order-orm.xml (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/order/order-persistence-2.xml (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/order/order-persistence-3.xml (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/order/order-persistence-4.xml (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/order/order-persistence.xml (with props)
Modified:
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMappingInfo.java
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerCollectionTableFieldStrategy.java
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationToManyTableFieldStrategy.java
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Column.java
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Compatibility.java
openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java
openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/MappingTag.java
openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java
openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingSerializer.java
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/oracle/TestAutoIncrement.java
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMFTestCase.java
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/MetaDataTag.java
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceStrategy.java
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataSerializer.java
Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMappingInfo.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMappingInfo.java?rev=736915&r1=736914&r2=736915&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMappingInfo.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMappingInfo.java Thu Jan 22 20:54:33 2009
@@ -22,6 +22,7 @@
import java.util.Collection;
import java.util.List;
+import org.apache.openjpa.conf.Compatibility;
import org.apache.openjpa.jdbc.schema.Column;
import org.apache.openjpa.jdbc.schema.ColumnIO;
import org.apache.openjpa.jdbc.schema.ForeignKey;
@@ -285,15 +286,25 @@
return null;
Column tmplate = new Column();
- tmplate.setName("ordr");
+ // Compatibility option determines what should be used for
+ // the default order column name
+ if (field.getMappingRepository().getConfiguration()
+ .getCompatibilityInstance().getUseJPA2DefaultOrderColumnName()) {
+ // Use the same strategy as column to build the field name
+ tmplate.setName(field.getName() + "_ORDER");
+ } else {
+ tmplate.setName("ordr");
+ }
+
tmplate.setJavaType(JavaTypes.INT);
if (!def.populateOrderColumns(field, table, new Column[]{ tmplate })
&& _orderCol == null)
return null;
- if (_orderCol != null && (_orderCol.getFlag(Column.FLAG_UNINSERTABLE)
- || _orderCol.getFlag(Column.FLAG_UNUPDATABLE))) {
+ if (_orderCol != null) {
ColumnIO io = new ColumnIO();
+ io.setNullInsertable(0, !_orderCol.isNotNull());
+ io.setNullUpdatable(0, !_orderCol.isNotNull());
io.setInsertable(0, !_orderCol.getFlag(Column.FLAG_UNINSERTABLE));
io.setUpdatable(0, !_orderCol.getFlag(Column.FLAG_UNUPDATABLE));
setColumnIO(io);
Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java?rev=736915&r1=736914&r2=736915&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java Thu Jan 22 20:54:33 2009
@@ -668,6 +668,8 @@
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
@@ -686,6 +688,8 @@
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
@@ -745,6 +749,8 @@
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
Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerCollectionTableFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerCollectionTableFieldStrategy.java?rev=736915&r1=736914&r2=736915&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerCollectionTableFieldStrategy.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerCollectionTableFieldStrategy.java Thu Jan 22 20:54:33 2009
@@ -148,8 +148,8 @@
ValueMapping elem = field.getElementMapping();
Column order = field.getOrderColumn();
- boolean setOrder = field.getOrderColumnIO().isInsertable(order, false);
- int idx = 0;
+ boolean setOrder = field.getOrderColumnIO().isInsertable(order, false);
+ int idx = (setOrder && order != null) ? order.getBase() : 0;
for (Iterator itr = coll.iterator(); itr.hasNext(); idx++) {
HandlerStrategies.set(elem, itr.next(), store, row, _cols,
_io, true);
Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationToManyTableFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationToManyTableFieldStrategy.java?rev=736915&r1=736914&r2=736915&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationToManyTableFieldStrategy.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationToManyTableFieldStrategy.java Thu Jan 22 20:54:33 2009
@@ -162,7 +162,7 @@
StoreContext ctx = sm.getContext();
Column order = field.getOrderColumn();
boolean setOrder = field.getOrderColumnIO().isInsertable(order, false);
- int idx = 0;
+ int idx = (setOrder && order != null) ? order.getBase() : 0;
OpenJPAStateManager esm;
for (Iterator itr = coll.iterator(); itr.hasNext(); idx++) {
esm = RelationStrategies.getStateManager(itr.next(), ctx);
Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Column.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Column.java?rev=736915&r1=736914&r2=736915&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Column.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Column.java Thu Jan 22 20:54:33 2009
@@ -76,6 +76,9 @@
private String _comment = null;
private boolean _XML = false;
+ private boolean _contiguous = true;
+ private int _base = 0;
+
/**
* Default constructor.
*/
@@ -724,6 +727,10 @@
_flags = from._flags;
if (!isXML())
setXML(from.isXML());
+ if (getBase() == 0)
+ setBase(from.getBase());
+ if (isContiguous())
+ setContiguous(from.isContiguous());
}
/**
@@ -783,4 +790,40 @@
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;
+ }
}
Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Compatibility.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Compatibility.java?rev=736915&r1=736914&r2=736915&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Compatibility.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Compatibility.java Thu Jan 22 20:54:33 2009
@@ -56,6 +56,7 @@
private int _jpql = JPQL_WARN;
private boolean _storeMapCollectionInEntityAsBlob = false;
private boolean _flushBeforeDetach = true;
+ private boolean _useJPA2DefaultOrderColumnName = true;
/**
* Whether to require exact identity value types when creating object
@@ -269,4 +270,27 @@
_flushBeforeDetach = beforeDetach;
}
+ /**
+ * Whether OpenJPA should use the new default order column name defined
+ * by JPA 2.0: name; "_"; "ORDER" or the pre-JPA 2.0 default name "ordr".
+ *
+ * @since 2.0.0
+ * @return true if the JPA2 default name should be used
+ */
+ public boolean getUseJPA2DefaultOrderColumnName() {
+ return _useJPA2DefaultOrderColumnName;
+ }
+
+ /**
+ * Whether OpenJPA should use the new default order column name defined
+ * by JPA 2.0: name; "_"; "ORDER" or the pre-JPA 2.0 default name "ordr".
+ *
+ * @param useJPA2 true if the JPA 2.0 default name should be used. false if
+ * the 1.x name should be used.
+ *
+ * @since 2.0.0
+ */
+ public void setUseJPA2DefaultOrderColumnName(boolean useJPA2Name) {
+ _useJPA2DefaultOrderColumnName = useJPA2Name;
+ }
}
Modified: openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java?rev=736915&r1=736914&r2=736915&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java Thu Jan 22 20:54:33 2009
@@ -176,6 +176,7 @@
_tags.put(MappingOverrides.class, MAPPING_OVERRIDES);
_tags.put(Nonpolymorphic.class, NONPOLY);
_tags.put(OrderColumn.class, ORDER_COL);
+ _tags.put(javax.persistence.OrderColumn.class, ORDER_COLUMN);
_tags.put(Strategy.class, STRAT);
_tags.put(SubclassFetchMode.class, SUBCLASS_FETCH_MODE);
_tags.put(Unique.class, UNIQUE);
@@ -1151,6 +1152,10 @@
fm.setPolymorphic(toPolymorphicConstant
(((Nonpolymorphic) anno).value()));
break;
+ case ORDER_COLUMN:
+ parseJavaxOrderColumn(fm,
+ (javax.persistence.OrderColumn)anno);
+ break;
case ORDER_COL:
parseOrderColumn(fm, (OrderColumn) anno);
break;
@@ -1660,7 +1665,7 @@
}
/**
- * Parse @OrderColumn.
+ * Parse @org.apache.openjpa.persistence.jdbc.OrderColumn.
*/
private void parseOrderColumn(FieldMapping fm, OrderColumn order) {
if (!order.enabled()) {
@@ -1679,6 +1684,28 @@
col.setFlag(Column.FLAG_UNUPDATABLE, !order.updatable());
fm.getMappingInfo().setOrderColumn(col);
}
+
+ /**
+ * Parse @javax.persistence.OrderColumn
+ */
+ private void parseJavaxOrderColumn(FieldMapping fm,
+ javax.persistence.OrderColumn order) {
+
+ Column col = new Column();
+ if (!StringUtils.isEmpty(order.name()))
+ col.setName(order.name());
+ if (!StringUtils.isEmpty(order.columnDefinition()))
+ col.setTypeName(order.columnDefinition());
+ col.setNotNull(!order.nullable());
+ col.setFlag(Column.FLAG_UNINSERTABLE, !order.insertable());
+ col.setFlag(Column.FLAG_UNUPDATABLE, !order.updatable());
+ if (!StringUtils.isEmpty(order.table()))
+ col.setTableName(order.table());
+ col.setBase(order.base());
+ col.setContiguous(order.contiguous());
+
+ fm.getMappingInfo().setOrderColumn(col);
+ }
/**
* Parse @ElementJoinColumn(s).
Modified: openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/MappingTag.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/MappingTag.java?rev=736915&r1=736914&r2=736915&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/MappingTag.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/MappingTag.java Thu Jan 22 20:54:33 2009
@@ -49,6 +49,7 @@
JOIN_COL,
JOIN_COLS,
JOIN_TABLE,
+ ORDER_COLUMN,
PK_JOIN_COL,
PK_JOIN_COLS,
SECONDARY_TABLE,
Modified: openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java?rev=736915&r1=736914&r2=736915&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java Thu Jan 22 20:54:33 2009
@@ -93,6 +93,7 @@
_elems.put("join-table", JOIN_TABLE);
_elems.put("map-key-column", MAP_KEY_COL);
_elems.put("map-key-join-column", MAP_KEY_JOIN_COL);
+ _elems.put("order-column", ORDER_COLUMN);
_elems.put("primary-key-join-column", PK_JOIN_COL);
_elems.put("secondary-table", SECONDARY_TABLE);
_elems.put("sql-result-set-mapping", SQL_RESULT_SET_MAPPING);
@@ -1078,5 +1079,65 @@
_discType = DiscriminatorType.STRING;
}
- }
+ }
+
+ /**
+ * Process OrderColumn.
+ */
+ protected boolean startOrderColumn(Attributes attrs)
+ throws SAXException {
+ Column col = parseOrderColumn(attrs);
+ Object obj = peekElement();
+ if (obj instanceof FieldMapping) {
+ FieldMapping fm = (FieldMapping)obj;
+ fm.getMappingInfo().setOrderColumn(col);
+ }
+ return true;
+ }
+ /**
+ * Create an order column with the given attributes.
+ */
+ private Column parseOrderColumn(Attributes attrs)
+ throws SAXException {
+
+ Column col = new Column();
+ String val = attrs.getValue("name");
+ if (val != null)
+ col.setName(val);
+ val = attrs.getValue("column-definition");
+ if (val != null)
+ col.setTypeName(val);
+ val = attrs.getValue("precision");
+ if (val != null)
+ col.setSize(Integer.parseInt(val));
+ val = attrs.getValue("length");
+ if (val != null)
+ col.setSize(Integer.parseInt(val));
+ val = attrs.getValue("scale");
+ if (val != null)
+ col.setDecimalDigits(Integer.parseInt(val));
+ val = attrs.getValue("nullable");
+ if (val != null)
+ col.setNotNull("false".equals(val));
+ val = attrs.getValue("insertable");
+ if (val != null)
+ col.setFlag(Column.FLAG_UNINSERTABLE, "false".equals(val));
+ 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) {
+ col.setTableName(val);
+ }
+ return col;
+ }
}
Modified: openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingSerializer.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingSerializer.java?rev=736915&r1=736914&r2=736915&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingSerializer.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingSerializer.java Thu Jan 22 20:54:33 2009
@@ -438,6 +438,35 @@
}
/**
+ * Serialize order column.
+ */
+ protected void serializeOrderColumn(FieldMetaData fmd)
+ throws SAXException {
+ FieldMapping field = (FieldMapping) fmd;
+ Column orderCol = field.getOrderColumn();
+ if (orderCol != null) {
+ if (orderCol.getName() != null)
+ addAttribute("name", orderCol.getName());
+ if (orderCol.isNotNull())
+ addAttribute("nullable", "false");
+ if (orderCol.getFlag(Column.FLAG_UNINSERTABLE))
+ addAttribute("insertable", "false");
+ if (orderCol.getFlag(Column.FLAG_UNUPDATABLE))
+ 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");
+ endElement("order-column");
+ }
+ }
+
+ /**
* Determine if the field is a lob.
*/
private boolean isLob(FieldMapping field) {
Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/oracle/TestAutoIncrement.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/oracle/TestAutoIncrement.java?rev=736915&r1=736914&r2=736915&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/oracle/TestAutoIncrement.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/oracle/TestAutoIncrement.java Thu Jan 22 20:54:33 2009
@@ -58,15 +58,6 @@
}
}
- boolean isTargetPlatform(String target) {
- String url = getPlatform();
- return url != null && url.indexOf(target) != -1;
- }
-
- public String getPlatform() {
- return System.getProperty("platform", "derby");
- }
-
public void testAutoIncrementIdentityWithNamedSequence() {
if (!isTargetPlatform(PLATFORM))
return;
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/BaseTestElement.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/BaseTestElement.java?rev=736915&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/BaseTestElement.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/BaseTestElement.java Thu Jan 22 20:54:33 2009
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.jdbc.order;
+
+public class BaseTestElement {
+
+ private int id;
+
+ private String name;
+
+
+ public BaseTestElement() {
+ }
+
+ public BaseTestElement(String name) {
+ this.name = name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof BaseTestElement) {
+ BaseTestElement bte = (BaseTestElement)obj;
+ return getId() == bte.getId() &&
+ bte.getName().equalsIgnoreCase(bte.getName());
+ }
+ return false;
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/BaseTestElement.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/BaseTestEntity.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/BaseTestEntity.java?rev=736915&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/BaseTestEntity.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/BaseTestEntity.java Thu Jan 22 20:54:33 2009
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.jdbc.order;
+
+import java.util.List;
+import java.util.Set;
+
+/*
+ * Entity used for testing custom column defintions base values.
+ */
+public class BaseTestEntity {
+
+ private int id;
+
+ private List<BaseTestElement> one2Melems;
+
+ private List<BaseTestElement> m2melems;
+
+ private Set<BaseTestElement> collelems;
+
+ public void setOne2Melems(List<BaseTestElement> one2Melems) {
+ this.one2Melems = one2Melems;
+ }
+
+ public List<BaseTestElement> getOne2Melems() {
+ return one2Melems;
+ }
+
+ public void setCollelems(Set<BaseTestElement> collelems) {
+ this.collelems = collelems;
+ }
+
+ public Set<BaseTestElement> getCollelems() {
+ return collelems;
+ }
+
+ public void setM2melems(List<BaseTestElement> m2melems) {
+ this.m2melems = m2melems;
+ }
+
+ public List<BaseTestElement> getM2melems() {
+ return m2melems;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public int getId() {
+ return id;
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/BaseTestEntity.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/BattingOrder.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/BattingOrder.java?rev=736915&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/BattingOrder.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/BattingOrder.java Thu Jan 22 20:54:33 2009
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.jdbc.order;
+
+import java.util.List;
+
+import javax.persistence.CascadeType;
+import javax.persistence.ElementCollection;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.OrderColumn;
+
+@Entity
+public class BattingOrder {
+
+ @Id
+ @GeneratedValue
+ int id;
+
+ @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
+ @OrderColumn
+ private List<Player> batters;
+
+ @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
+ @OrderColumn(name="pinch_order")
+ private List<Player> pinch_hitters;
+
+ @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
+ @OrderColumn(insertable=true, updatable=false)
+ private List<Player> fixedBatters;
+
+ @ElementCollection
+ @OrderColumn(insertable=false)
+ private List<String> titles;
+
+ public void setBatters(List<Player> batters) {
+ this.batters = batters;
+ }
+
+ public List<Player> getBatters() {
+ return batters;
+ }
+
+ public void setPinchHitters(List<Player> pinch_hitters) {
+ this.pinch_hitters = pinch_hitters;
+ }
+
+ public List<Player> getPinchHitters() {
+ return pinch_hitters;
+ }
+
+ public void setFixedBatters(List<Player> fixedBatters) {
+ this.fixedBatters = fixedBatters;
+ }
+
+ public List<Player> getFixedBatters() {
+ return fixedBatters;
+ }
+
+ public void setTitles(List<String> titles) {
+ this.titles = titles;
+ }
+
+ public List<String> getTitles() {
+ return titles;
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/BattingOrder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/ColDefTestElement.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/ColDefTestElement.java?rev=736915&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/ColDefTestElement.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/ColDefTestElement.java Thu Jan 22 20:54:33 2009
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.jdbc.order;
+
+import javax.persistence.Basic;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class ColDefTestElement {
+
+ @Id
+ @GeneratedValue
+ private int id;
+
+ @Basic
+ private String name;
+
+
+ public ColDefTestElement() {
+ }
+
+ public ColDefTestElement(String name) {
+ this.name = name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof ColDefTestElement) {
+ ColDefTestElement bte = (ColDefTestElement)obj;
+ return getId() == bte.getId() &&
+ bte.getName().equalsIgnoreCase(bte.getName());
+ }
+ return false;
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/ColDefTestElement.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/ColDefTestEntity.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/ColDefTestEntity.java?rev=736915&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/ColDefTestEntity.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/ColDefTestEntity.java Thu Jan 22 20:54:33 2009
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.jdbc.order;
+
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.ElementCollection;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import javax.persistence.OneToMany;
+import javax.persistence.OrderColumn;
+
+/*
+ * Entity used for testing order column base values. All metadata and
+ * mapping information is defined in order-orm.xml
+ */
+
+@Entity
+public class ColDefTestEntity {
+
+ @Id
+ @GeneratedValue
+ private int id;
+
+ @OneToMany(cascade=CascadeType.PERSIST)
+ @OrderColumn(name="one2McoldefOrder", columnDefinition="BIGINT")
+ private List<ColDefTestElement> one2Mcoldef;
+
+ @ElementCollection
+ @OrderColumn(name="colcoldefOrder", columnDefinition="BIGINT")
+ private Set<ColDefTestElement> collcoldef;
+
+ @ManyToMany(cascade=CascadeType.PERSIST)
+ @OrderColumn(name="m2McoldefOrder", columnDefinition="BIGINT")
+ private List<ColDefTestElement> m2mcoldef;
+
+ public void setOne2Mcoldef(List<ColDefTestElement> one2Mcoldef) {
+ this.one2Mcoldef = one2Mcoldef;
+ }
+
+ public List<ColDefTestElement> getOne2Mcoldef() {
+ return one2Mcoldef;
+ }
+
+ public void setCollcoldef(Set<ColDefTestElement> collcoldef) {
+ this.collcoldef = collcoldef;
+ }
+
+ public Set<ColDefTestElement> getCollcoldef() {
+ return collcoldef;
+ }
+
+ public void setM2mcoldef(List<ColDefTestElement> m2mcoldef) {
+ this.m2mcoldef = m2mcoldef;
+ }
+
+ public List<ColDefTestElement> getM2mcoldef() {
+ return m2mcoldef;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public int getId() {
+ return id;
+ }
+}
\ No newline at end of file
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/ColDefTestEntity.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Course.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Course.java?rev=736915&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Course.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Course.java Thu Jan 22 20:54:33 2009
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.jdbc.order;
+
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.OrderColumn;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="OCCourse")
+public class Course {
+
+ private int id;
+
+ private String name;
+
+ private Set<Student> students;
+ private List<Student> waitList;
+
+ public Course() {
+ }
+
+ public Course(String name) {
+ this.name = name;
+ }
+
+ @ManyToMany(cascade=CascadeType.PERSIST)
+ @JoinTable(name="COURSE_ENROLLMENT")
+ public Set<Student> getStudents() {
+ return students;
+ }
+
+ public void setStudents(Set<Student> students) {
+ this.students = students;
+ }
+
+ @ManyToMany(cascade=CascadeType.PERSIST)
+ @JoinTable(name="WAIT_LIST")
+ @OrderColumn(name="WAITLIST_ORDER")
+ public List<Student> getWaitList() {
+ return waitList;
+ }
+
+ public void setWaitList(List<Student> list) {
+ waitList = list;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @Id
+ @GeneratedValue
+ public int getId() {
+ return id;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Basic
+ public String getName() {
+ return name;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof Course) {
+ Course course = (Course)obj;
+ return getId() == course.getId() &&
+ getName().equalsIgnoreCase(course.getName());
+ }
+ return false;
+ }
+
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Course.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Game.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Game.java?rev=736915&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Game.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Game.java Thu Jan 22 20:54:33 2009
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.jdbc.order;
+
+import java.util.Collection;
+import java.util.List;
+
+import javax.persistence.ElementCollection;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.OrderColumn;
+
+@Entity
+@Table(name="OCGame")
+public class Game {
+
+ @Id
+ @GeneratedValue(generator="uuid-type4-hex")
+ private String id;
+
+ @ManyToMany
+ @OrderColumn(name="playerOrder")
+ private List<Player> playedIn;
+
+ @ElementCollection
+ @OrderColumn(name="dateOrder")
+ private List<java.sql.Date> rainDates;
+
+ @ElementCollection
+ @OrderColumn(name="inningOrder")
+ private Collection<Inning> innings;
+
+ public Game() {
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setPlayedIn(List<Player> playedIn) {
+ this.playedIn = playedIn;
+ }
+
+ public List<Player> getPlayedIn() {
+ return playedIn;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof Game) {
+ Game game = (Game)obj;
+ return getId().equals(game.getId());
+ }
+ return false;
+ }
+
+ public void setRainDates(List<java.sql.Date> rainDates) {
+ this.rainDates = rainDates;
+ }
+
+ public List<java.sql.Date> getRainDates() {
+ return rainDates;
+ }
+
+ public void setInnings(Collection<Inning> innings) {
+ this.innings = innings;
+ }
+
+ public Collection<Inning> getInnings() {
+ return innings;
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Game.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Inning.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Inning.java?rev=736915&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Inning.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Inning.java Thu Jan 22 20:54:33 2009
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.jdbc.order;
+
+import javax.persistence.Embeddable;
+
+@Embeddable
+public class Inning {
+
+ private int number;
+
+ private int hitsHome;
+
+ private int hitsAway;
+
+ public Inning() {
+ }
+
+ public Inning(int num, int hh, int ha) {
+ number = num;
+ hitsHome = hh;
+ hitsAway = ha;
+ }
+
+ public void setNumber(int number) {
+ this.number = number;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+
+ public void setHitsHome(int hitsHome) {
+ this.hitsHome = hitsHome;
+ }
+
+ public int getHitsHome() {
+ return hitsHome;
+ }
+
+ public void setHitsAway(int hitsAway) {
+ this.hitsAway = hitsAway;
+ }
+
+ public int getHitsAway() {
+ return hitsAway;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof Inning) {
+ Inning in = (Inning)obj;
+ return getNumber() == in.getNumber() &&
+ getHitsHome() == in.getHitsHome() &&
+ getHitsAway() == in.getHitsAway();
+ }
+ return false;
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Inning.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/ObOcEntity.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/ObOcEntity.java?rev=736915&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/ObOcEntity.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/ObOcEntity.java Thu Jan 22 20:54:33 2009
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.jdbc.order;
+
+import java.util.List;
+
+import javax.persistence.ElementCollection;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OrderBy;
+import javax.persistence.OrderColumn;
+
+@Entity
+public class ObOcEntity {
+
+ @Id
+ @GeneratedValue
+ private int id;
+
+ @OrderBy("ASC")
+ @OrderColumn(name="myCol")
+ @ElementCollection
+ private List<Integer> intList;
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setIntList(List<Integer> intList) {
+ this.intList = intList;
+ }
+
+ public List<Integer> getIntList() {
+ return intList;
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/ObOcEntity.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Person.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Person.java?rev=736915&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Person.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Person.java Thu Jan 22 20:54:33 2009
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.jdbc.order;
+
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+
+@MappedSuperclass
+public abstract class Person {
+
+ @Id
+ @GeneratedValue(generator="uuid-type4-hex")
+ private String id;
+
+ private String name;
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof Player) {
+ Player player = (Player)obj;
+ return getId().equalsIgnoreCase(player.getId()) &&
+ player.getName().equals(getName());
+ }
+ return false;
+ }
+
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Person.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Player.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Player.java?rev=736915&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Player.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Player.java Thu Jan 22 20:54:33 2009
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.jdbc.order;
+
+import java.util.List;
+
+import javax.persistence.Entity;
+import javax.persistence.ManyToMany;
+import javax.persistence.OrderColumn;
+
+@Entity
+public class Player extends Person {
+
+ private int number;
+
+ @ManyToMany(mappedBy="playersTrained")
+ private List<Trainer> trainers;
+
+ @ManyToMany(mappedBy="playedIn")
+ @OrderColumn(name="playedInOrder")
+ private List<Game> gamesPlayedIn;
+
+ public Player() {
+ }
+
+ public Player(String name, int number) {
+ setName(name);
+ this.number = number;
+ }
+
+ public void setNumber(int number) {
+ this.number = number;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+
+ public void setTrainers(List<Trainer> trainers) {
+ this.trainers = trainers;
+ }
+
+ public List<Trainer> getTrainers() {
+ return trainers;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof Player) {
+ Player player = (Player)obj;
+ return super.equals(obj) &&
+ player.getNumber() == number;
+ }
+ return false;
+ }
+
+ public void setGamesPlayedIn(List<Game> gamesPlayedIn) {
+ this.gamesPlayedIn = gamesPlayedIn;
+ }
+
+ public List<Game> getGamesPlayedIn() {
+ return gamesPlayedIn;
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Player.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Student.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Student.java?rev=736915&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Student.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Student.java Thu Jan 22 20:54:33 2009
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.jdbc.order;
+
+import java.util.Set;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="OCStudent")
+public class Student {
+
+ private int id;
+
+ private String name;
+
+ private Set<Course> courses;
+
+ public Student() {
+ }
+
+ public Student(String name) {
+ this.name = name;
+ }
+
+ @ManyToMany(mappedBy="students",cascade=CascadeType.PERSIST)
+ public Set<Course> getCourses() {
+ return courses;
+ }
+
+ public void setCourses(Set<Course> courses) {
+ this.courses = courses;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @Id
+ @GeneratedValue
+ public int getId() {
+ return id;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Basic
+ public String getName() {
+ return name;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof Student) {
+ Student student = (Student)obj;
+ return getId() == student.getId() &&
+ getName().equalsIgnoreCase(student.getName());
+ }
+ return false;
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Student.java
------------------------------------------------------------------------------
svn:eol-style = native