Author: ssegu
Date: Tue Nov 11 14:32:29 2008
New Revision: 713200
URL: http://svn.apache.org/viewvc?rev=713200&view=rev
Log:
OPENJPA-536 - Merging changes back.
Added:
openjpa/branches/0.9.7-r547073/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceOrderedMetaDataList.java
- copied, changed from r650559,
openjpa/branches/1.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceOrderedMetaDataList.java
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/A.java
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/AbstractThing.java
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/Artist.java
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/B.java
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/C.java
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/Item.java
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/Painter.java
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/Person.java
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/TestGetMetaData.java
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/TestMetaDataInheritanceComparator.java
Modified:
openjpa/branches/0.9.7-r547073/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceComparator.java
openjpa/branches/0.9.7-r547073/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
Modified:
openjpa/branches/0.9.7-r547073/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceComparator.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/0.9.7-r547073/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceComparator.java?rev=713200&r1=713199&r2=713200&view=diff
==============================================================================
---
openjpa/branches/0.9.7-r547073/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceComparator.java
(original)
+++
openjpa/branches/0.9.7-r547073/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceComparator.java
Tue Nov 11 14:32:29 2008
@@ -40,6 +40,10 @@
_base = base;
}
+ public Class getBase() {
+ return _base;
+ }
+
/**
* Subclasses can override this method to extract the class to compare
* on from the elements of the collection.
@@ -75,7 +79,12 @@
return 1;
return c1.getName().compareTo(c2.getName());
}
- return i1 - i2;
+ if (i1 < i2)
+ return -1;
+ else if (i1 > i2)
+ return 1;
+ else
+ return 0;
}
/**
Copied:
openjpa/branches/0.9.7-r547073/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceOrderedMetaDataList.java
(from r650559,
openjpa/branches/1.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceOrderedMetaDataList.java)
URL:
http://svn.apache.org/viewvc/openjpa/branches/0.9.7-r547073/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceOrderedMetaDataList.java?p2=openjpa/branches/0.9.7-r547073/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceOrderedMetaDataList.java&p1=openjpa/branches/1.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceOrderedMetaDataList.java&r1=650559&r2=713200&rev=713200&view=diff
==============================================================================
---
openjpa/branches/1.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceOrderedMetaDataList.java
(original)
+++
openjpa/branches/0.9.7-r547073/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceOrderedMetaDataList.java
Tue Nov 11 14:32:29 2008
@@ -28,12 +28,14 @@
private MetaDataInheritanceComparator _comp
= new MetaDataInheritanceComparator();
- private LinkedList<ClassMetaData> buffer = new LinkedList<ClassMetaData>();
+ private LinkedList buffer = new LinkedList();
public boolean add(ClassMetaData meta) {
- for (ListIterator<ClassMetaData> itr = buffer.listIterator();
+ if (meta == null || buffer.contains(meta))
+ return false;
+ for (ListIterator itr = buffer.listIterator();
itr.hasNext();) {
- int ord = _comp.compare(meta, itr.next());
+ int ord = _comp.compare(meta, (ClassMetaData) itr.next());
if (ord > 0)
continue;
if (ord == 0)
@@ -51,14 +53,14 @@
}
public ClassMetaData peek() {
- return buffer.peek();
+ return (ClassMetaData) buffer.peek();
}
public int size() {
return buffer.size();
}
- public Iterator<ClassMetaData> iterator() {
+ public Iterator iterator() {
return buffer.iterator();
}
Modified:
openjpa/branches/0.9.7-r547073/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/0.9.7-r547073/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java?rev=713200&r1=713199&r2=713200&view=diff
==============================================================================
---
openjpa/branches/0.9.7-r547073/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
(original)
+++
openjpa/branches/0.9.7-r547073/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
Tue Nov 11 14:32:29 2008
@@ -29,7 +29,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.SortedSet;
import java.util.TreeSet;
import org.apache.commons.lang.StringUtils;
@@ -127,10 +126,10 @@
private final Collection _registered = new ArrayList();
// set of metadatas we're in the process of resolving
- private final SortedSet _resolving = new TreeSet
- (new MetaDataInheritanceComparator());
- private final SortedSet _mapping = new TreeSet
- (new MetaDataInheritanceComparator());
+ private final InheritanceOrderedMetaDataList _resolving =
+ new InheritanceOrderedMetaDataList();
+ private final InheritanceOrderedMetaDataList _mapping =
+ new InheritanceOrderedMetaDataList();
private final List _errs = new LinkedList();
// system listeners
@@ -558,7 +557,7 @@
// resolved
return processBuffer(meta, _resolving, MODE_META);
}
-
+
/**
* Load mapping information for the given metadata.
*/
@@ -639,7 +638,8 @@
/**
* Process the given metadata and the associated buffer.
*/
- private List processBuffer(ClassMetaData meta, SortedSet buffer, int mode)
{
+ private List processBuffer(ClassMetaData meta,
+ InheritanceOrderedMetaDataList buffer, int mode) {
// if we're already processing a metadata, just buffer this one; when
// the initial metadata finishes processing, we traverse the buffer
// and process all the others that were introduced during reentrant
@@ -654,7 +654,7 @@
ClassMetaData buffered;
List processed = new ArrayList(5);
while (!buffer.isEmpty()) {
- buffered = (ClassMetaData) buffer.first();
+ buffered = buffer.peek();
try {
buffered.resolve(mode);
processed.add(buffered);
Added:
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/A.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/A.java?rev=713200&view=auto
==============================================================================
---
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/A.java
(added)
+++
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/A.java
Tue Nov 11 14:32:29 2008
@@ -0,0 +1,28 @@
+/*
+ * 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.meta;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
[EMAIL PROTECTED]
[EMAIL PROTECTED](name="meta_A")
+public class A extends AbstractThing {
+
+}
Added:
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/AbstractThing.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/AbstractThing.java?rev=713200&view=auto
==============================================================================
---
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/AbstractThing.java
(added)
+++
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/AbstractThing.java
Tue Nov 11 14:32:29 2008
@@ -0,0 +1,41 @@
+/*
+ * 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.meta;
+
+import javax.persistence.MappedSuperclass;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Column;
+
[EMAIL PROTECTED]
+public class AbstractThing {
+
+ private String id;
+
+ @Id
+ @GeneratedValue(generator = "uuid-hex")
+ @Column(columnDefinition = "char(32)")
+ public String getId() {
+ return id;
+ }
+
+ protected void setId(final String id) {
+ this.id = id;
+ }
+}
Added:
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/Artist.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/Artist.java?rev=713200&view=auto
==============================================================================
---
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/Artist.java
(added)
+++
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/Artist.java
Tue Nov 11 14:32:29 2008
@@ -0,0 +1,42 @@
+/*
+ * 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.meta;
+
+import javax.persistence.Entity;
+
[EMAIL PROTECTED]
+public class Artist
+ extends Person {
+
+ /**
+ * Default constructor required for enhancement.
+ */
+ public Artist() {
+ super();
+ }
+
+ /**
+ * The public constructor constructs with a name.
+ *
+ * @param name the name of the artist.
+ */
+ public Artist(String name) {
+ super(name);
+ }
+}
Added:
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/B.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/B.java?rev=713200&view=auto
==============================================================================
---
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/B.java
(added)
+++
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/B.java
Tue Nov 11 14:32:29 2008
@@ -0,0 +1,51 @@
+/*
+ * 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.meta;
+
+import java.util.Set;
+import javax.persistence.Entity;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+import org.apache.openjpa.meta.C;
+
[EMAIL PROTECTED]
[EMAIL PROTECTED](name="meta_B")
+public class B extends AbstractThing {
+ private Set<C> cs;
+ private Set<A> as;
+
+ @OneToMany
+ public Set<C> getCs() {
+ return cs;
+ }
+
+ public void setCs(Set<C> cs) {
+ this.cs = cs;
+ }
+
+ @OneToMany
+ public Set<A> getAs() {
+ return as;
+ }
+
+ public void setAs(Set<A> as) {
+ this.as = as;
+ }
+}
Added:
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/C.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/C.java?rev=713200&view=auto
==============================================================================
---
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/C.java
(added)
+++
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/C.java
Tue Nov 11 14:32:29 2008
@@ -0,0 +1,103 @@
+/*
+ * 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.meta;
+
+import javax.persistence.Entity;
+import javax.persistence.IdClass;
+import javax.persistence.ManyToOne;
+import javax.persistence.Column;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.apache.openjpa.meta.C.Identity;
+
[EMAIL PROTECTED]
[EMAIL PROTECTED](Identity.class)
[EMAIL PROTECTED](name="meta_C")
+public class C {
+ private A a;
+ private B b;
+ private long num;
+
+ @ManyToOne(optional = false)
+ @Column(nullable = false)
+ public A getA() {
+ return a;
+ }
+
+ public void setA(A a) {
+ this.a = a;
+ }
+
+ @Id
+ @ManyToOne(optional = false)
+ @Column(nullable = false)
+ public B getB() {
+ return b;
+ }
+
+ public void setB(B b) {
+ this.b = b;
+ }
+
+ @Id
+ public long getNum() {
+ return num;
+ }
+
+ public void setNum(long num) {
+ this.num = num;
+ }
+
+ public static class Identity {
+ private String b;
+ private long num;
+
+ @Override
+ public int hashCode() {
+ return b.hashCode() * 17 + (int) num;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj != null && (obj instanceof Identity)
+ && b.equals(((Identity) obj).b) && num == ((Identity) obj).num;
+ }
+
+ public String getB() {
+ return b;
+ }
+
+ public void setB(B b) {
+ this.b = b.getId();
+ }
+
+ public void setB(String b) {
+ this.b = b;
+ }
+
+ public long getNum() {
+ return num;
+ }
+
+ public void setNum(long num) {
+ this.num = num;
+ }
+ }
+}
Added:
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/Item.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/Item.java?rev=713200&view=auto
==============================================================================
---
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/Item.java
(added)
+++
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/Item.java
Tue Nov 11 14:32:29 2008
@@ -0,0 +1,110 @@
+/*
+ * 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.meta;
+
+import java.io.Serializable;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+
[EMAIL PROTECTED]
+public class Item implements Serializable {
+
+ @Id
+ @GeneratedValue
+ private int id;
+
+ private String title;
+
+ @ManyToOne(cascade = CascadeType.PERSIST)
+ private Artist artist;
+
+ /**
+ * A no-arg constructor is required for enhancement.
+ */
+ protected Item() {
+ super();
+ }
+
+ /**
+ * The public constructor constructs with a title.
+ *
+ * @param title the title of the item.
+ */
+ public Item(String title) {
+ super();
+ this.title = title;
+ }
+
+ /**
+ * Gets the unique identifier of this receiver. There is no corresponding
+ * <code>setId()</code> method as the identifier value is generated by the
+ * Persistence Provider Runtime.
+ *
+ * @return unique identifier of this instance.
+ */
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * Gets the title of this item.
+ *
+ * @return return the tile of the item.
+ */
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * Sets the title of this receiver.
+ *
+ * @param title must not be null or empty.
+ */
+ public void setTitle(String title) {
+ if (title == null || title.trim().length() == 0)
+ throw new IllegalArgumentException(
+ "null or empty title not allowed");
+ this.title = title;
+ }
+
+ /**
+ * Gets the artist who created this item. This is an example of
+ * unidirectional single-valued relationship.
+ *
+ * @return the artist who created this item.
+ */
+ public Artist getArtist() {
+ return artist;
+ }
+
+ /**
+ * Sets the artist who created this Item.
+ *
+ * @param artist must not be null.
+ */
+ public void setArtist(Artist artist) {
+ if (artist == null)
+ throw new IllegalArgumentException("null Artist for " + this);
+
+ this.artist = artist;
+ }
+}
Added:
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/Painter.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/Painter.java?rev=713200&view=auto
==============================================================================
---
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/Painter.java
(added)
+++
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/Painter.java
Tue Nov 11 14:32:29 2008
@@ -0,0 +1,33 @@
+/*
+ * 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.meta;
+
+import javax.persistence.Entity;
+
[EMAIL PROTECTED]
+public class Painter extends Artist {
+
+ public Painter() {
+ super();
+ }
+
+ public Painter(String name) {
+ super(name);
+ }
+}
Added:
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/Person.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/Person.java?rev=713200&view=auto
==============================================================================
---
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/Person.java
(added)
+++
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/Person.java
Tue Nov 11 14:32:29 2008
@@ -0,0 +1,78 @@
+/*
+ * 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.meta;
+
+import java.io.Serializable;
+import java.util.Collection;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
[EMAIL PROTECTED]
+public class Person implements Serializable {
+
+ @Id
+ private String name;
+
+ @OneToMany
+ private Collection<Painter> paitersForPortrait;
+
+ /**
+ * default constructor required by enhancement.
+ */
+ protected Person() {
+
+ }
+
+ /**
+ * The public constructor constructs with a name.
+ *
+ * @param name the name of the person.
+ */
+
+ public Person(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Gets the name of this person. This is the unique identifier.
+ *
+ * @return return the name of this person.
+ */
+ public String getName() {
+
+ return name;
+ }
+
+ public void setName(String name) {
+ if (name == null || name.trim().length() == 0)
+ throw new IllegalArgumentException(
+ "null or empty name not allowed");
+ this.name = name;
+ }
+
+ public Collection<Painter> getPainters() {
+
+ return paitersForPortrait;
+ }
+
+ public void setPainters(Collection<Painter> p) {
+ this.paitersForPortrait = p;
+ }
+}
Added:
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/TestGetMetaData.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/TestGetMetaData.java?rev=713200&view=auto
==============================================================================
---
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/TestGetMetaData.java
(added)
+++
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/TestGetMetaData.java
Tue Nov 11 14:32:29 2008
@@ -0,0 +1,36 @@
+/*
+ * 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.meta;
+
+import org.apache.openjpa.meta.MetaDataRepository;
+import org.apache.openjpa.persistence.test.SingleEMFTestCase;
+
+public class TestGetMetaData extends SingleEMFTestCase {
+
+ public void setUp() {
+ setUp(Item.class, Person.class, Artist.class, Painter.class,
+ CLEAR_TABLES);
+ }
+
+ public void testGetMetaData() {
+ MetaDataRepository mr =
emf.getConfiguration().getMetaDataRepositoryInstance();
+ assertNotNull(mr.getMetaData(Item.class, null, false));
+ assertNotNull(mr.getMetaData(Person.class, null, false));
+ }
+}
Added:
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/TestMetaDataInheritanceComparator.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/TestMetaDataInheritanceComparator.java?rev=713200&view=auto
==============================================================================
---
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/TestMetaDataInheritanceComparator.java
(added)
+++
openjpa/branches/0.9.7-r547073/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/TestMetaDataInheritanceComparator.java
Tue Nov 11 14:32:29 2008
@@ -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.meta;
+
+import javax.persistence.EntityManagerFactory;
+
+import org.apache.openjpa.persistence.test.PersistenceTestCase;
+import org.apache.openjpa.meta.MetaDataRepository;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
+
+public class TestMetaDataInheritanceComparator extends PersistenceTestCase {
+
+ public void testInheritanceComparatorWithBase() {
+ inheritanceComparatorHelper(true);
+ }
+
+ private void inheritanceComparatorHelper(boolean base) {
+ InheritanceComparator comp = new InheritanceComparator();
+ if (base)
+ comp.setBase(AbstractThing.class);
+
+ assertEquals(-1, comp.compare(A.class, B.class));
+ assertEquals(-1, comp.compare(B.class, C.class));
+ assertTrue(comp.compare(A.class, C.class) < 0);
+
+ assertEquals(-1, comp.compare(AbstractThing.class, A.class));
+ assertEquals(-1, comp.compare(AbstractThing.class, B.class));
+ assertTrue(comp.compare(AbstractThing.class, C.class) < 0);
+ }
+
+ public void testMetaDataInheritanceComparatorWithBase() {
+ metaDataInheritanceComparatorHelper(true);
+ }
+
+ private void metaDataInheritanceComparatorHelper(boolean base) {
+ InheritanceComparator comp = new MetaDataInheritanceComparator();
+ if (base)
+ comp.setBase(AbstractThing.class);
+
+ OpenJPAEntityManagerFactory emf = createEMF(A.class, B.class, C.class,
+ AbstractThing.class);
+
+ MetaDataRepository mr = emf.getConfiguration().
+ getMetaDataRepositoryInstance();
+ ClassMetaData a = mr.getMetaData(A.class, null, false);
+ ClassMetaData b = mr.getMetaData(B.class, null, false);
+ ClassMetaData c = mr.getMetaData(C.class, null, false);
+ ClassMetaData at = mr.getMetaData(AbstractThing.class, null, false);
+
+ emf.close();
+
+ assertEquals(-1, comp.compare(a, b));
+ assertEquals(-1, comp.compare(b, c));
+ assertTrue(comp.compare(a, c) < 0);
+
+ assertEquals(1, comp.compare(b, a));
+ assertEquals(1, comp.compare(c, b));
+ assertTrue(comp.compare(c, a) > 0);
+
+ assertEquals(-1, comp.compare(at, a));
+ assertEquals(-1, comp.compare(at, b));
+ assertEquals(-1, comp.compare(at, c));
+ }
+
+ public void testEndToEnd() {
+ // make sure we can get things fully instantiated
+ EntityManagerFactory emf = createEMF(A.class, B.class, C.class,
+ AbstractThing.class);
+ emf.createEntityManager().close();
+ emf.close();
+ }
+}