diff --git a/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java b/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java index b00badc85..db041f607 100644 --- a/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java +++ b/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java @@ -1690,6 +1690,14 @@ public class AnnotationPersistenceMappingParser */ private void parseJavaxOrderColumn(FieldMapping fm, javax.persistence.OrderColumn order) { + // If a table name is specified on the annotation and a table + // name has not been defined, set the table name to the name + // specified. This will be the name of the join table or + // collection table. + if (!StringUtils.isEmpty(order.table()) && + StringUtils.isEmpty(fm.getMappingInfo().getTableName())) { + fm.getMappingInfo().setTableName(order.table()); + } Column col = new Column(); if (!StringUtils.isEmpty(order.name())) diff --git a/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java b/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java index a6dcca55f..78f28d934 100644 --- a/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java +++ b/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java @@ -1091,6 +1091,15 @@ public class XMLPersistenceMappingParser if (obj instanceof FieldMapping) { FieldMapping fm = (FieldMapping)obj; fm.getMappingInfo().setOrderColumn(col); + + // If a table name is specified on the element and a table + // name has not been defined, set the table name to the name + // specified. This will be the name of the join table or + // collection table. + if (!StringUtils.isEmpty(col.getTableName()) && + StringUtils.isEmpty(fm.getMappingInfo().getTableName())) { + fm.getMappingInfo().setTableName(col.getTableName()); + } } return true; } diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Bicycle.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Bicycle.java new file mode 100644 index 000000000..15477ecf8 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Bicycle.java @@ -0,0 +1,65 @@ +/* + * 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.Column; +import javax.persistence.Embeddable; + +@Embeddable +public class Bicycle { + + @Column(name="bike_brand") + private String brand; + + @Column(name="bike_model") + private String model; + + public Bicycle() { + } + + public Bicycle(String brand, String model) { + this.brand = brand; + this.model = model; + } + + public void setBrand(String brand) { + this.brand = brand; + } + + public String getBrand() { + return brand; + } + + public void setModel(String model) { + this.model = model; + } + + public String getModel() { + return model; + } + + public boolean equals(Object obj) { + if (obj instanceof Bicycle) { + Bicycle bike = (Bicycle)obj; + return getBrand().equals(bike.getBrand()) && + getModel().equals(bike.getModel()); + } + return false; + } +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Car.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Car.java new file mode 100644 index 000000000..aef7da2f0 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Car.java @@ -0,0 +1,108 @@ +/* + * 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; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +@Entity +@Table(name="OC_CAR") +public class Car { + + @Id + @GeneratedValue + private int id; + + @ManyToOne + private Owner owner; + + @Basic + private int modelYear; + + @Basic + private String make; + + @Basic + private String model; + + public Car() { + } + + public Car(int year, String make, String model){ + this.modelYear = year; + this.make = make; + this.model = model; + } + + public void setId(int id) { + this.id = id; + } + + public int getId() { + return id; + } + + public void setModelYear(int year) { + this.modelYear = year; + } + + public int getModelYear() { + return modelYear; + } + + public void setMake(String make) { + this.make = make; + } + + public String getMake() { + return make; + } + + public void setModel(String model) { + this.model = model; + } + + public String getModel() { + return model; + } + + public void setOwner(Owner owner) { + this.owner = owner; + } + + public Owner getOwner() { + return owner; + } + + public boolean equals(Object obj) { + if (obj instanceof Car) { + Car car = (Car)obj; + return getId() == car.getId() && + getMake().equals(car.getMake()) && + getModel().equals(car.getModel()) && + getModelYear() == car.getModelYear(); + } + return false; + } +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Home.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Home.java new file mode 100644 index 000000000..fddc0c59b --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Home.java @@ -0,0 +1,67 @@ +/* + * 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 Home { + + @Id + @GeneratedValue + private int id; + + @Basic + private int buildYear; + + public Home() { + } + + public Home(int year) { + this.buildYear = year; + } + + public void setId(int id) { + this.id = id; + } + + public int getId() { + return id; + } + + public void setBuildYear(int buildYear) { + this.buildYear = buildYear; + } + + public int getBuildYear() { + return buildYear; + } + + public boolean equals(Object obj) { + if (obj instanceof Home) { + Home home = (Home)obj; + return getBuildYear() == home.getBuildYear() && + getId() == home.getId(); + } + return false; + } +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Owner.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Owner.java new file mode 100644 index 000000000..f29d9d355 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Owner.java @@ -0,0 +1,92 @@ +/* + * 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 javax.persistence.CascadeType; +import javax.persistence.ElementCollection; +import javax.persistence.Entity; +import javax.persistence.Inheritance; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToMany; +import javax.persistence.OneToMany; +import javax.persistence.OrderColumn; +import javax.persistence.Table; + +import static javax.persistence.InheritanceType.SINGLE_TABLE; + +@Entity +@Table(name="OC_OWNER") +@Inheritance(strategy=SINGLE_TABLE) +public class Owner extends Person { + + // bidirectional one-to-many w/ default join column + @OneToMany(mappedBy="owner", cascade=CascadeType.ALL) + @OrderColumn(name="car_o2m_order", table="car_o2m_table") + private Collection cars; + + // unidirectional one-to-many w/ join column + @OneToMany(cascade=CascadeType.ALL) + @OrderColumn(table="home_o2m_table") + private Collection homes; + + @ManyToMany(cascade=CascadeType.ALL) + @OrderColumn(table="widget_m2m_table") + private Collection widgets; + + // element collection + @ElementCollection + @OrderColumn(name="bike_coll_order", table="bike_table") + private Collection bikeColl; + + + + public void setCars(Collection cars) { + this.cars = cars; + } + + public Collection getCars() { + return cars; + } + + public void setHomes(Collection homes) { + this.homes = homes; + } + + public Collection getHomes() { + return homes; + } + + public void setBikeColl(Collection bikeColl) { + this.bikeColl = bikeColl; + } + + public Collection getBikeColl() { + return bikeColl; + } + + public void setWidgets(Collection widgets) { + this.widgets = widgets; + } + + public Collection getWidgets() { + return widgets; + } +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/TestOrderColumn.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/TestOrderColumn.java index b870d8019..5aba9e47f 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/TestOrderColumn.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/TestOrderColumn.java @@ -22,6 +22,9 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.SQLException; import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; @@ -38,6 +41,9 @@ import org.apache.openjpa.jdbc.conf.JDBCConfiguration; 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.jdbc.schema.Sequence; +import org.apache.openjpa.jdbc.schema.Table; +import org.apache.openjpa.jdbc.sql.DBDictionary; import org.apache.openjpa.lib.meta.MetaDataSerializer; import org.apache.openjpa.meta.ClassMetaData; import org.apache.openjpa.meta.MetaDataRepository; @@ -57,7 +63,9 @@ public class TestOrderColumn extends SingleEMFTestCase { super.setUp(DROP_TABLES, Person.class, Player.class, BattingOrder.class, Trainer.class, Game.class, Inning.class, - Course.class, Student.class); + Course.class, Student.class, + Owner.class, Bicycle.class, Car.class, Home.class, + Widget.class); try { createQueryData(); } catch (Exception e) { @@ -639,10 +647,13 @@ public class TestOrderColumn extends SingleEMFTestCase { new Object[] { elems[6], elems[7], elems[8]}, "id", bte.getId()); -// This test is disabled until INDEX projection supports element collections +// This validator is disabled until INDEX projection supports element +// collections // validateIndexAndValues(em, "BaseTestEntity", "collelems", 10, -// new Object[] { elems[0], elems[1], elems[2]}); +// new Object[] { elems[0], elems[1], elems[2]} "id", +// bte.getId()); + em.close(); try { if (emf1 != null) cleanupEMF(emf1); @@ -652,20 +663,118 @@ public class TestOrderColumn extends SingleEMFTestCase { } /* - * Validates the use of the table attribute on OrderColumn + * Validates the use of the table attribute on OrderColumn with + * o2o, o2m, m2m, and collection table - with and without join + * tables. */ - public void verifyOrderColumnTable() { - /* - * If the relationship is a many-to-many or unidirectional one-to-many - * relationship, the table is the join table for the relationship. If - * the relationship is a bidirectional one-to-many or unidirectional - * one-to-many mapped by a join column, the table is the primary - * table for the entity on the mapny side of the relationship. If the - * ordering is for a collection of elements, the table is the - * collection table for the element collection. - */ + public void testOrderColumnTable() { + + OpenJPAEntityManagerSPI em = emf.createEntityManager(); + + validateOrderColumnTable(emf, Owner.class, "cars", + "OC_CAR", "car_o2m_order"); + + validateOrderColumnTable(emf, Owner.class, "homes", + "home_o2m_table", "homes_ORDER"); + + validateOrderColumnTable(emf, Owner.class, "bikeColl", + "bike_table", "bike_coll_order"); + + validateOrderColumnTable(emf, Owner.class, "widgets", + "widget_m2m_table", "widgets_ORDER"); + + Owner owner = new Owner(); + Collection cars = new ArrayList(); + Collection homes = new ArrayList(); + Collection bicycles = new ArrayList(); + Collection widgets = new ArrayList(); + Collection owners = new ArrayList(); + owner.setCars(cars); + owner.setHomes(homes); + owner.setBikeColl(bicycles); + owner.setWidgets(widgets); + + for (int i = 0; i < 5; i++){ + Car car = new Car(2000 + 1, "Make"+i, "Model"+i); + car.setOwner(owner); + cars.add(car); + + Home home = new Home(2000 + i); + homes.add(home); + + Bicycle bike = new Bicycle("Brand"+i, "Model"+i); + bicycles.add(bike); + + Widget widget = new Widget("Name"+i); + widgets.add(widget); + widget.setOwners(owners); + } + + Object[] carArr = cars.toArray(); + Object[] homeArr = homes.toArray(); + Object[] bikeArr = bicycles.toArray(); + Object[] widgetArr = widgets.toArray(); + + em.getTransaction().begin(); + em.persist(owner); + em.getTransaction().commit(); + String oid = owner.getId(); + + em.clear(); + + // Run queries to ensure the query component uses the correct tables + validateIndexAndValues(em, "Owner", "cars", 0, + carArr, "id", + oid); + + validateIndexAndValues(em, "Owner", "homes", 0, + homeArr, "id", + oid); + + validateIndexAndValues(em, "Owner", "widgets", 0, + widgetArr, "id", + oid); + +// This validator is disabled until INDEX projection supports element +// collections +// validateIndexAndValues(em, "Owner", "bikeColl", 0, +// bikeArr, "id", +// oid); + + em.close(); } - + + /** + * Validates the use of the table attribute defined in XML + */ + public void testOrderColumnTableXML() { + + OpenJPAEntityManagerFactorySPI emf1 = + (OpenJPAEntityManagerFactorySPI)OpenJPAPersistence. + createEntityManagerFactory("TableTest", + "org/apache/openjpa/persistence/jdbc/order/" + + "order-persistence-5.xml"); + + OpenJPAEntityManagerSPI em = emf1.createEntityManager(); + + validateOrderColumnTable(emf1, BaseTestEntity.class, "one2Melems", + "xml_o2m_table", "one2MOrder"); + + validateOrderColumnTable(emf1, BaseTestEntity.class, "m2melems", + "xml_m2m_table", "m2morder"); + + validateOrderColumnTable(emf1, BaseTestEntity.class, "collelems", + "xml_coll_table", "collelems_ORDER"); + + em.close(); + try { + if (emf1 != null) + cleanupEMF(emf1); + } catch (Exception e) { + fail(e.getMessage()); + } + } + /* * Validates the use of order column (via INDEX) in the predicate of a * JPQL query. @@ -698,7 +807,9 @@ public class TestOrderColumn extends SingleEMFTestCase { qry.setParameter("widx", 1); idx0 = (Student)qry.getSingleResult(); assertNotNull(idx0); - assertEquals(idx0, students[10]); + assertEquals(idx0, students[10]); + + em.close(); } /* @@ -727,6 +838,8 @@ public class TestOrderColumn extends SingleEMFTestCase { Long idx = (Long)qry.getSingleResult(); assertNotNull(idx); assertEquals((Long)idx, (Long)1L); + + em.close(); } /* @@ -735,14 +848,15 @@ public class TestOrderColumn extends SingleEMFTestCase { */ public void testOrderColumnOrderBy() { + OpenJPAEntityManagerFactorySPI emf1 = null; + OpenJPAEntityManagerSPI em = null; try { - OpenJPAEntityManagerFactorySPI emf1 = - (OpenJPAEntityManagerFactorySPI)OpenJPAPersistence. + emf1 = (OpenJPAEntityManagerFactorySPI)OpenJPAPersistence. createEntityManagerFactory("ObOcTest", "org/apache/openjpa/persistence/jdbc/order/" + "order-persistence-3.xml"); - OpenJPAEntityManagerSPI em = emf1.createEntityManager(); + em = emf1.createEntityManager(); ObOcEntity ent = new ObOcEntity(); List intList = new ArrayList(); @@ -755,10 +869,20 @@ public class TestOrderColumn extends SingleEMFTestCase { em.getTransaction().commit(); em.close(); + em = null; fail("An exception should have been thrown."); } catch (Exception e) { assertException(e, ArgumentException.class); + } finally { + if (em != null) + em.close(); } + try { + if (emf1 != null) + cleanupEMF(emf1); + } catch (Exception e) { + fail(e.getMessage()); + } } public void testOrderColumnMetaDataSerialization() @@ -809,7 +933,14 @@ public class TestOrderColumn extends SingleEMFTestCase { oc = fm.getOrderColumn(); assertNotNull(oc); assertEquals(oc.getName(),"collelems_ORDER"); - assertEquals(oc.getBase(), 10); + assertEquals(oc.getBase(), 10); + + try { + if (emf1 != null) + cleanupEMF(emf1); + } catch (Exception e) { + fail(e.getMessage()); + } } /* @@ -852,6 +983,7 @@ public class TestOrderColumn extends SingleEMFTestCase { em.persist(courseA); em.persist(courseB); em.getTransaction().commit(); + em.close(); } private void validateIndexAndValues(OpenJPAEntityManagerSPI em, @@ -898,7 +1030,19 @@ public class TestOrderColumn extends SingleEMFTestCase { Column oc = getOrderColumn(emf1, clazz, fieldName); assertTrue(oc.getName().equalsIgnoreCase(columnName)); } - + + private void validateOrderColumnTable( + OpenJPAEntityManagerFactorySPI emf1, + Class clazz, String fieldName, String tableName, + String columnName) { + Column oc = getOrderColumn(emf1, clazz, fieldName); + // Verify the oc has the correct table name + assertTrue(oc.getTableName().equalsIgnoreCase(tableName)); + // 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) { @@ -934,6 +1078,44 @@ public class TestOrderColumn extends SingleEMFTestCase { assertEquals(insertable, !oc.getFlag(Column.FLAG_DIRECT_INSERT)); } + /** + * Method to verify a table was created for the given name and schema + */ + private boolean tableAndColumnExists(OpenJPAEntityManagerFactorySPI emf1, + OpenJPAEntityManagerSPI em, String tableName, String schemaName, + String columnName) { + JDBCConfiguration conf = (JDBCConfiguration) emf1.getConfiguration(); + DBDictionary dict = conf.getDBDictionaryInstance(); + OpenJPAEntityManagerSPI em1 = em; + + // If no em supplied, create one + if (em1 == null) { + em1 = emf1.createEntityManager(); + } + Connection conn = (Connection)em1.getConnection(); + try { + DatabaseMetaData dbmd = conn.getMetaData(); + // (meta, catalog, schemaName, tableName, conn) + Column[] cols = dict.getColumns(dbmd, null, null, + tableName, columnName, conn); + if (cols != null && cols.length == 1) { + Column col = cols[0]; + String colName = col.getName(); + if (col.getTableName().equalsIgnoreCase(tableName) && + (schemaName == null || + col.getSchemaName().equalsIgnoreCase(schemaName)) && + colName.equalsIgnoreCase(columnName)) + return true; + } + } catch (Throwable e) { + fail("Unable to get column information."); + } finally { + if (em == null) { + em1.close(); + } + } + return false; + } /** * Closes a specific entity manager factory and cleans up * associated tables. diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Widget.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Widget.java new file mode 100644 index 000000000..2b397ef1a --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/order/Widget.java @@ -0,0 +1,81 @@ +/* + * 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 javax.persistence.Basic; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToMany; + +@Entity +public class Widget { + + @Id + @GeneratedValue(generator="uuid-hex") + private String id; + + @Basic + private String name; + + @ManyToMany(mappedBy="widgets") + private Collection owners; + + public Widget() { + } + + public Widget(String name) { + this.name = name; + } + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setOwners(Collection owners) { + this.owners = owners; + } + + public Collection getOwners() { + return owners; + } + + public boolean equals(Object obj) { + if (obj instanceof Widget) { + Widget widget = (Widget)obj; + return getId().equals(widget.getId()) && + getName().equals(widget.getName()); + } + return false; + } +} diff --git a/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/order/order-orm-3.xml b/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/order/order-orm-3.xml new file mode 100644 index 000000000..6c892f754 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/order/order-orm-3.xml @@ -0,0 +1,63 @@ + + + + + org.apache.openjpa.persistence.jdbc.order + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/order/order-persistence-5.xml b/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/order/order-persistence-5.xml new file mode 100644 index 000000000..bdc4e7dd1 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/order/order-persistence-5.xml @@ -0,0 +1,36 @@ + + + + + PU for order column testing + org.apache.openjpa.persistence.PersistenceProviderImpl + org/apache/openjpa/persistence/jdbc/order/order-orm-3.xml + org.apache.openjpa.persistence.jdbc.order.BaseTestEntity + org.apache.openjpa.persistence.jdbc.order.BaseTestElement + + + + + \ No newline at end of file