openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r590529 [1/2] - in /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence: jdbc/annotations/ test/
Date Wed, 31 Oct 2007 01:27:25 GMT
Author: pcl
Date: Tue Oct 30 18:27:23 2007
New Revision: 590529

URL: http://svn.apache.org/viewvc?rev=590529&view=rev
Log:
Additional test cases for JPA annotations; commented-out test for OPENJPA-425.

Added:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/AnnoTest1.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/AnnoTest2.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/AnnoTest3.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbedOwner.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbedValue.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbedValue2.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbeddableSuper.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbeddableSuperSub.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbeddedIdClass.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbeddedIdEntity.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/ExtensionsEntity.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/Flat1.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/Flat2.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/Generator.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/PropertyAccess1.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TablePerClass1.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TablePerClass2.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestDiscriminator.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestEJBEmbedded.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestEmbeddableSuperclass.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestEmbeddedId.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestEnumerated.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestExtensionAnnotations.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestFlatInheritance.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestJoinedInheritance.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestManyToMany.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestMapKey.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestOneToMany.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestOneToOne.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestPropertyAccess.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestSerializedLobs.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestTablePerClassInheritance.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestVersion.java
Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/AnnoTest1.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/AnnoTest1.java?rev=590529&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/AnnoTest1.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/AnnoTest1.java Tue Oct 30 18:27:23 2007
@@ -0,0 +1,312 @@
+/*
+ * 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.annotations;
+
+
+import java.util.*;
+
+import javax.persistence.*;
+
+import org.apache.openjpa.persistence.jdbc.*;
+
+@Entity
+@Table(name = "ANNOTEST1")
+@Inheritance(strategy = InheritanceType.JOINED)
+@DiscriminatorColumn(name = "ANNOCLS")
+@DiscriminatorValue("ANNO1")
+@SecondaryTables({ @SecondaryTable(name = "OTHER_ANNOTEST1",
+    pkJoinColumns = @PrimaryKeyJoinColumn(name = "OTHER_PK",
+        referencedColumnName = "PK")) })
+public class AnnoTest1 {
+
+    @Id
+    @Column(name = "PK")
+    protected Long pk;
+
+    @Version
+    @Column(name = "ANNOVER")
+    protected int version;
+
+    @Basic
+    protected int basic;
+
+    @Transient
+    protected int trans;
+
+    @Basic
+    @Column(name = "OTHERVALUE", table = "OTHER_ANNOTEST1")
+    protected int otherTableBasic;
+
+    @OneToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name = "SELFONEONE_PK", referencedColumnName = "PK")
+    protected AnnoTest1 selfOneOne;
+
+    @OneToOne
+    @PrimaryKeyJoinColumn
+    protected AnnoTest1 pkJoinSelfOneOne;
+
+    @OneToOne
+    @JoinColumns({
+    @JoinColumn(name = "ONEONE_PK1", referencedColumnName = "PK1"),
+    @JoinColumn(name = "ONEONE_PK2", referencedColumnName = "PK2") })
+    protected AnnoTest2 oneOne;
+
+    @OneToOne(fetch = FetchType.LAZY)
+    @JoinColumns({
+    @JoinColumn(name = "OTHERONE_PK1", referencedColumnName = "PK1",
+        table = "OTHER_ANNOTEST1"),
+    @JoinColumn(name = "OTHERONE_PK2", referencedColumnName = "PK2",
+        table = "OTHER_ANNOTEST1") })
+    protected AnnoTest2 otherTableOneOne;
+
+    @OneToOne(mappedBy = "inverseOneOne", fetch = FetchType.LAZY)
+    protected AnnoTest2 inverseOwnerOneOne;
+
+    @Lob
+    @Column(name = "BLOBVAL")
+    protected byte[] blob;
+
+    @Basic
+    @Lob
+    @Column(name = "SERVAL")
+    protected Object serial;
+
+    @Column(name = "CLOBVAL")
+    @Lob
+    protected String clob;
+
+    // un-annotated enum should be persisted by default
+    @Column(name = "ENUMVAL")
+    protected InheritanceType enumeration;
+
+    @Enumerated
+    @Column(name = "ORD_ENUMVAL")
+    protected InheritanceType ordinalEnumeration;
+
+    @Enumerated(EnumType.STRING)
+    @Column(name = "STR_ENUMVAL")
+    protected InheritanceType stringEnumeration;
+
+    @OneToMany
+    @ElementJoinColumn(name = "ONEMANY_PK", referencedColumnName = "PK")
+    protected Set<AnnoTest2> oneMany = new HashSet();
+
+    @OneToMany(mappedBy = "oneManyOwner")
+    protected Set<AnnoTest2> inverseOwnerOneMany = new HashSet();
+
+    @ManyToMany
+    @JoinTable(name = "ANNOTEST1_MANYMANY",
+        joinColumns = @JoinColumn(name = "MANY_PK"),
+        inverseJoinColumns = {
+        @JoinColumn(name = "MANY_PK1", referencedColumnName = "PK1"),
+        @JoinColumn(name = "MANY_PK2", referencedColumnName = "PK2") })
+    protected Set<AnnoTest2> manyMany = new HashSet();
+
+    @ManyToMany(mappedBy = "manyMany")
+    protected Set<AnnoTest2> inverseOwnerManyMany = new HashSet();
+
+    @MapKey
+    @OneToMany
+    protected Map<Integer, Flat1> defaultMapKey = new HashMap();
+
+    @MapKey(name = "basic")
+    @OneToMany
+    protected Map<Integer, Flat1> namedMapKey = new HashMap();
+
+    @MapKey(name = "basic")
+    @OneToMany(mappedBy = "oneManyOwner")
+    protected Map<String, AnnoTest2> inverseOwnerMapKey = new HashMap();
+
+    public AnnoTest1() {
+    }
+
+    public AnnoTest1(long pk) {
+        this(new Long(pk));
+    }
+
+    public AnnoTest1(Long pk) {
+        this.pk = pk;
+    }
+
+    public void setPk(Long val) {
+        pk = val;
+    }
+
+    public Long getPk() {
+        return pk;
+    }
+
+    public int getVersion() {
+        return version;
+    }
+
+    public void setBasic(int i) {
+        basic = i;
+    }
+
+    public int getBasic() {
+        return basic;
+    }
+
+    public void setTransient(int i) {
+        trans = i;
+    }
+
+    public int getTransient() {
+        return trans;
+    }
+
+    public void setOtherTableBasic(int i) {
+        otherTableBasic = i;
+    }
+
+    public int getOtherTableBasic() {
+        return otherTableBasic;
+    }
+
+    public void setSelfOneOne(AnnoTest1 other) {
+        selfOneOne = other;
+    }
+
+    public AnnoTest1 getSelfOneOne() {
+        return selfOneOne;
+    }
+
+    public void setPKJoinSelfOneOne(AnnoTest1 other) {
+        pkJoinSelfOneOne = other;
+    }
+
+    public AnnoTest1 getPKJoinSelfOneOne() {
+        return pkJoinSelfOneOne;
+    }
+
+    public void setOneOne(AnnoTest2 other) {
+        oneOne = other;
+    }
+
+    public AnnoTest2 getOneOne() {
+        return oneOne;
+    }
+
+    public void setOtherTableOneOne(AnnoTest2 other) {
+        otherTableOneOne = other;
+    }
+
+    public AnnoTest2 getOtherTableOneOne() {
+        return otherTableOneOne;
+    }
+
+    public void setInverseOwnerOneOne(AnnoTest2 other) {
+        inverseOwnerOneOne = other;
+    }
+
+    public AnnoTest2 getInverseOwnerOneOne() {
+        return inverseOwnerOneOne;
+    }
+
+    public void setBlob(byte[] bytes) {
+        blob = bytes;
+    }
+
+    public byte[] getBlob() {
+        return blob;
+    }
+
+    public void setSerialized(Object o) {
+        serial = o;
+    }
+
+    public Object getSerialized() {
+        return serial;
+    }
+
+    public void setClob(String s) {
+        clob = s;
+    }
+
+    public String getClob() {
+        return clob;
+    }
+
+    public InheritanceType getEnumeration() {
+        return enumeration;
+    }
+
+    public void setEnumeration(InheritanceType val) {
+        enumeration = val;
+    }
+
+    public InheritanceType getOrdinalEnumeration() {
+        return ordinalEnumeration;
+    }
+
+    public void setOrdinalEnumeration(InheritanceType val) {
+        ordinalEnumeration = val;
+    }
+
+    public InheritanceType getStringEnumeration() {
+        return stringEnumeration;
+    }
+
+    public void setStringEnumeration(InheritanceType val) {
+        stringEnumeration = val;
+    }
+
+    public Set<AnnoTest2> getOneMany() {
+        return oneMany;
+    }
+
+    public Set<AnnoTest2> getInverseOwnerOneMany() {
+        return inverseOwnerOneMany;
+    }
+
+    public Set<AnnoTest2> getManyMany() {
+        return manyMany;
+    }
+
+    public Set<AnnoTest2> getInverseOwnerManyMany() {
+        return inverseOwnerManyMany;
+    }
+
+    public Map<Integer, Flat1> getDefaultMapKey() {
+        return this.defaultMapKey;
+    }
+
+    public void setDefaultMapKey(Map<Integer, Flat1> defaultMapKey) {
+        this.defaultMapKey = defaultMapKey;
+    }
+
+    public Map<Integer, Flat1> getNamedMapKey() {
+        return this.namedMapKey;
+    }
+
+    public void setNamedMapKey(Map<Integer, Flat1> namedMapKey) {
+        this.namedMapKey = namedMapKey;
+    }
+
+    public Map<String, AnnoTest2> getInverseOwnerMapKey() {
+        return this.inverseOwnerMapKey;
+    }
+
+    public void setInverseOwnerMapKey(
+        Map<String, AnnoTest2> inverseOwnerMapKey) {
+        this.inverseOwnerMapKey = inverseOwnerMapKey;
+    }
+}
+

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/AnnoTest2.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/AnnoTest2.java?rev=590529&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/AnnoTest2.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/AnnoTest2.java Tue Oct 30 18:27:23 2007
@@ -0,0 +1,166 @@
+/*
+ * 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.annotations;
+
+
+import java.util.*;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "ANNOTEST2")
+@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
+@DiscriminatorColumn(name = "ANNOCLS")
+@DiscriminatorValue("ANNO2")
+@IdClass(AnnoTest2.Oid.class)
+public class AnnoTest2 {
+
+    @Id
+    @Column(name = "PK1")
+    protected long pk1;
+
+    @Id
+    @Column(name = "PK2")
+    protected String pk2;
+
+    @Version
+    @Column(name = "ANNOVER")
+    protected Date version;
+
+    @Basic
+    protected String basic;
+
+    @OneToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name = "INVERSEONEONE_PK", referencedColumnName = "PK")
+    protected AnnoTest1 inverseOneOne;
+
+    @ManyToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name = "MANYONEONE_PK", referencedColumnName = "PK")
+    protected AnnoTest1 oneManyOwner;
+
+    @ManyToMany
+    @JoinTable(name = "ANNOTEST2_MANYMANY",
+        joinColumns = {
+        @JoinColumn(name = "MANY_PK1", referencedColumnName = "PK1"),
+        @JoinColumn(name = "MANY_PK2", referencedColumnName = "PK2") },
+        inverseJoinColumns =
+        @JoinColumn(name = "MANYE_PK", referencedColumnName = "PK"))
+    protected Set<AnnoTest1> manyMany = new HashSet();
+
+    public AnnoTest2() {
+    }
+
+    public AnnoTest2(long pk1, String pk2) {
+        this.pk1 = pk1;
+        this.pk2 = pk2;
+    }
+
+    public void setPk1(long val) {
+        pk1 = val;
+    }
+
+    public long getPk1() {
+        return pk1;
+    }
+
+    public void setPk2(String str) {
+        pk2 = str;
+    }
+
+    public String getPk2() {
+        return pk2;
+    }
+
+    public Date getVersion() {
+        return version;
+    }
+
+    public void setBasic(String s) {
+        basic = s;
+    }
+
+    public String getBasic() {
+        return basic;
+    }
+
+    public void setInverseOneOne(AnnoTest1 other) {
+        inverseOneOne = other;
+    }
+
+    public AnnoTest1 getInverseOneOne() {
+        return inverseOneOne;
+    }
+
+    public void setOneManyOwner(AnnoTest1 other) {
+        oneManyOwner = other;
+    }
+
+    public AnnoTest1 getOneManyOwner() {
+        return oneManyOwner;
+    }
+
+    public Set getManyMany() {
+        return manyMany;
+    }
+
+    public static class Oid {
+
+        public long pk1;
+        public String pk2;
+
+        public Oid() {
+        }
+
+        public Oid(long pk1, String pk2) {
+            this.pk1 = pk1;
+            this.pk2 = pk2;
+        }
+
+        public Oid(String str) {
+            if (str != null) {
+                int index = str.indexOf(",");
+                pk1 = Long.parseLong(str.substring(0, index));
+                pk2 = str.substring(index + 1);
+                if ("null".equals(pk2))
+                    pk2 = null;
+            }
+        }
+
+        public boolean equals(Object o) {
+            if (o == this)
+                return true;
+            if (!(o instanceof Oid))
+                return false;
+            Oid other = (Oid) o;
+            if (pk1 != other.pk1)
+                return false;
+            if (pk2 == null)
+                return other.pk2 == null;
+            return pk2.equals(other.pk2);
+        }
+
+        public int hashCode() {
+            return ((int) pk1) + (pk2 == null ? 0 : pk2.hashCode());
+        }
+
+        public String toString() {
+            return pk1 + "," + (pk2 == null ? "null" : pk2);
+        }
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/AnnoTest3.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/AnnoTest3.java?rev=590529&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/AnnoTest3.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/AnnoTest3.java Tue Oct 30 18:27:23 2007
@@ -0,0 +1,64 @@
+/*
+ * 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.annotations;
+
+
+import javax.persistence.*;
+
+@Entity
+@DiscriminatorValue("ANNO3")
+@Table(name = "ANNOTEST3")
+@PrimaryKeyJoinColumns(@PrimaryKeyJoinColumn(name = "SUB_PK",
+    referencedColumnName = "PK"))
+public class AnnoTest3 extends AnnoTest1 {
+
+    @Basic
+    @Column(name = "SUBBASIC")
+    protected int basic2;
+
+    @OneToOne(fetch = FetchType.LAZY)
+    protected AnnoTest2 subOneOne;
+
+    public AnnoTest3() {
+    }
+
+    public AnnoTest3(long pk) {
+        super(pk);
+    }
+
+    public AnnoTest3(Long pk) {
+        super(pk);
+    }
+
+    public void setBasic2(int i) {
+        basic2 = i;
+    }
+
+    public int getBasic2() {
+        return basic2;
+    }
+
+    public AnnoTest2 getSubOneOne() {
+        return subOneOne;
+    }
+
+    public void setSubOneOne(AnnoTest2 anno2) {
+        subOneOne = anno2;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbedOwner.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbedOwner.java?rev=590529&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbedOwner.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbedOwner.java Tue Oct 30 18:27:23 2007
@@ -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.annotations;
+
+
+import javax.persistence.*;
+
+@Entity
+@SqlResultSetMapping(name = "EmbedMapping", entities = {
+@EntityResult(entityClass = EmbedOwner.class, fields = {
+@FieldResult(name = "pk", column = "OWNER_PK"),
+@FieldResult(name = "basic", column = "OWNER_BASIC"),
+@FieldResult(name = "embed.basic", column = "EMBED_BASIC"),
+@FieldResult(name = "embed.clob", column = "EMBED_CLOB")
+    })
+    })
+public class EmbedOwner {
+
+    @Embedded
+    @AttributeOverride(name = "basic", column = @Column(name = "OVER_BASIC"))
+    @AssociationOverride(name = "owner",
+        joinColumns = @JoinColumn(name = "OVER_OWNER"))
+    protected EmbedValue embed;
+
+    @Basic
+    @Column(name = "OWN_BASIC")
+    protected String basic;
+
+    @Id
+    @GeneratedValue
+    protected int pk;
+
+    public int getPk() {
+        return pk;
+    }
+
+    public void setBasic(String basic) {
+        this.basic = basic;
+    }
+
+    public String getBasic() {
+        return basic;
+    }
+
+    public void setEmbed(EmbedValue embed) {
+        this.embed = embed;
+    }
+
+    public EmbedValue getEmbed() {
+        return embed;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbedValue.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbedValue.java?rev=590529&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbedValue.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbedValue.java Tue Oct 30 18:27:23 2007
@@ -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.annotations;
+
+
+import javax.persistence.*;
+
+@Embeddable
+public class EmbedValue {
+
+    @Basic
+    @Column(name = "EMB_BASIC")
+    protected String basic;
+
+    @Lob
+    @Column(name = "EMB_CLOB")
+    protected String clob;
+
+    @Lob
+    @Column(name = "EMB_BLOB")
+    protected byte[] blob;
+
+    @ManyToOne
+    @JoinColumn(name = "EMB_REL")
+    protected EmbedOwner owner;
+
+    public void setBasic(String basic) {
+        this.basic = basic;
+    }
+
+    public String getBasic() {
+        return basic;
+    }
+
+    public void setClob(String clob) {
+        this.clob = clob;
+    }
+
+    public String getClob() {
+        return clob;
+    }
+
+    public void setBlob(byte[] blob) {
+        this.blob = blob;
+    }
+
+    public byte[] getBlob() {
+        return blob;
+    }
+
+    public void setOwner(EmbedOwner owner) {
+        this.owner = owner;
+    }
+
+    public EmbedOwner getOwner() {
+        return owner;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbedValue2.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbedValue2.java?rev=590529&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbedValue2.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbedValue2.java Tue Oct 30 18:27:23 2007
@@ -0,0 +1,54 @@
+/*
+ * 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.annotations;
+
+
+import javax.persistence.*;
+
+/**
+ * Same as EmbedValue but no blobs for suitable use as key/value/element
+ * in oracle.
+ */
+@Embeddable
+public class EmbedValue2 {
+
+    @Basic
+    @Column(name = "EMB_BASIC")
+    protected String basic;
+
+    @Basic
+    @Column(name = "EMB_INTBASIC")
+    protected int intBasic;
+
+    public void setBasic(String basic) {
+        this.basic = basic;
+    }
+
+    public String getBasic() {
+        return basic;
+    }
+
+    public void setIntBasic(int intBasic) {
+        this.intBasic = intBasic;
+    }
+
+    public int getIntBasic() {
+        return intBasic;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbeddableSuper.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbeddableSuper.java?rev=590529&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbeddableSuper.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbeddableSuper.java Tue Oct 30 18:27:23 2007
@@ -0,0 +1,77 @@
+/*
+ * 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.annotations;
+
+
+import javax.persistence.*;
+
+@MappedSuperclass
+public class EmbeddableSuper {
+
+    @Id
+    @GeneratedValue
+    @Column(name = "ID")
+    private long pk;
+
+    @Version
+    @Column(name = "SUPVERS")
+    private int version;
+
+    @Transient
+    private int trans;
+
+    @Lob
+    @Column(name = "CLOBVAL")
+    protected String clob;
+
+    public EmbeddableSuper() {
+    }
+
+    public long getPK() {
+        return this.pk;
+    }
+
+    public void setPK(long pk) {
+        this.pk = pk;
+    }
+
+    public int getTrans() {
+        return this.trans;
+    }
+
+    public void setTrans(int trans) {
+        this.trans = trans;
+    }
+
+    public String getClob() {
+        return this.clob;
+    }
+
+    public void setClob(String clob) {
+        this.clob = clob;
+    }
+
+    public int getVersion() {
+        return this.version;
+    }
+
+    public void setVersion(int version) {
+        this.version = version;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbeddableSuperSub.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbeddableSuperSub.java?rev=590529&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbeddableSuperSub.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbeddableSuperSub.java Tue Oct 30 18:27:23 2007
@@ -0,0 +1,58 @@
+/*
+ * 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.annotations;
+
+
+import javax.persistence.*;
+
+@Entity
+@DiscriminatorColumn(name = "DISC")
+@AttributeOverrides({
+    @AttributeOverride(name = "clob", column = @Column(name = "CC")),
+    @AttributeOverride(name = "version", column = @Column(name = "VERSVAL"))
+})
+public class EmbeddableSuperSub
+    extends EmbeddableSuper {
+
+    @ManyToOne
+    private EmbeddableSuperSub sub;
+
+    @ManyToOne
+    // #####
+    private EmbeddableSuper sup;
+
+    public EmbeddableSuperSub() {
+    }
+
+    public EmbeddableSuperSub getSub() {
+        return this.sub;
+    }
+
+    public void setSub(EmbeddableSuperSub sub) {
+        this.sub = sub;
+    }
+
+    public EmbeddableSuper getSup() {
+        return this.sup;
+    }
+
+    public void setSup(EmbeddableSuper sup) {
+        this.sup = sup;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbeddedIdClass.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbeddedIdClass.java?rev=590529&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbeddedIdClass.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbeddedIdClass.java Tue Oct 30 18:27:23 2007
@@ -0,0 +1,80 @@
+/*
+ * 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.annotations;
+
+
+import javax.persistence.*;
+
+@Embeddable
+public class EmbeddedIdClass {
+
+    @Column(name = "EPK1")
+    private long pk1;
+
+    @Column(name = "EPK2")
+    private long pk2;
+
+    @Column(name = "EPK3")
+    @GeneratedValue
+    private long pk3;
+
+    public long getPk1() {
+        return pk1;
+    }
+
+    public void setPk1(long pk1) {
+        this.pk1 = pk1;
+    }
+
+    public long getPk2() {
+        return pk2;
+    }
+
+    public void setPk2(long pk2) {
+        this.pk2 = pk2;
+    }
+
+    public long getPk3() {
+        return pk3;
+    }
+
+    public void setPk3(long pk3) {
+        this.pk3 = pk3;
+    }
+
+    public String toString() {
+        return pk1 + ":" + pk2 + ":" + pk3;
+    }
+
+    public int hashCode() {
+        return (int) ((pk1 ^ pk2 ^ pk3) % Integer.MAX_VALUE);
+    }
+
+    public boolean equals(Object other) {
+        if (other == this)
+            return true;
+        if (!(other instanceof EmbeddedIdClass))
+            return false;
+
+        EmbeddedIdClass id = (EmbeddedIdClass) other;
+        return id.pk1 == pk1
+            && id.pk2 == pk2
+            && id.pk3 == pk3;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbeddedIdEntity.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbeddedIdEntity.java?rev=590529&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbeddedIdEntity.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/EmbeddedIdEntity.java Tue Oct 30 18:27:23 2007
@@ -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.annotations;
+
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "EMIDENTITY")
+@SqlResultSetMapping(name = "EmbeddedIdMapping", entities = {
+@EntityResult(entityClass = EmbeddedIdEntity.class, fields = {
+@FieldResult(name = "id.pk1", column = "OWNER_PK1"),
+@FieldResult(name = "id.pk2", column = "OWNER_PK2"),
+@FieldResult(name = "id.pk3", column = "OWNER_PK3"),
+@FieldResult(name = "value", column = "OWNER_VAL"),
+@FieldResult(name = "relation.id.pk1", column = "REL_PK1"),
+@FieldResult(name = "relation.id.pk2", column = "REL_PK2"),
+@FieldResult(name = "relation.id.pk3", column = "REL_PK3")
+    }),
+@EntityResult(entityClass = EmbeddedIdEntity.class, fields = {
+@FieldResult(name = "id.pk1", column = "REL_PK1"),
+@FieldResult(name = "id.pk2", column = "REL_PK2"),
+@FieldResult(name = "id.pk3", column = "REL_PK3"),
+@FieldResult(name = "value", column = "REL_VAL")
+    })
+    })
+public class EmbeddedIdEntity {
+
+    @EmbeddedId
+    private EmbeddedIdClass id;
+
+    @Column(name = "VAL")
+    private String value;
+
+    @ManyToOne
+    private EmbeddedIdEntity relation;
+
+    @ManyToOne
+    @JoinColumns({
+    @JoinColumn(name = "MREL_PK1", referencedColumnName = "EPK1"),
+    @JoinColumn(name = "MREL_PK2", referencedColumnName = "EPK2")
+        })
+    private EmbeddedIdEntity mapOverrideRelation;
+
+    public EmbeddedIdClass getId() {
+        return id;
+    }
+
+    public void setId(EmbeddedIdClass id) {
+        this.id = id;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public EmbeddedIdEntity getRelation() {
+        return relation;
+    }
+
+    public void setRelation(EmbeddedIdEntity relation) {
+        this.relation = relation;
+    }
+
+    public EmbeddedIdEntity getMappingOverrideRelation() {
+        return mapOverrideRelation;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/ExtensionsEntity.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/ExtensionsEntity.java?rev=590529&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/ExtensionsEntity.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/ExtensionsEntity.java Tue Oct 30 18:27:23 2007
@@ -0,0 +1,94 @@
+/*
+ * 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.annotations;
+
+
+import java.util.*;
+
+import javax.persistence.*;
+
+import org.apache.openjpa.jdbc.meta.strats.*;
+import org.apache.openjpa.persistence.*;
+import org.apache.openjpa.persistence.jdbc.*;
+
+
+@Entity
+@DataStoreId(strategy = GenerationType.SEQUENCE, generator = "system")
+@DataCache(enabled = false)
+@FetchGroup(name = "detail", attributes = {
+    @FetchAttribute(name = "rel", recursionDepth = -1),
+    @FetchAttribute(name = "seq")
+})
+@VersionStrategy(StateComparisonVersionStrategy.ALIAS)
+public class ExtensionsEntity {
+
+    @GeneratedValue(generator = "uuid-hex")
+    @Column(name = "UUID_HEX")
+    private String uuid;
+
+    @Basic(fetch = FetchType.LAZY)
+    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "system")
+    @ReadOnly
+    private int seq;
+
+    @ManyToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name = "REL_ID", referencedColumnName = "ID")
+    @Dependent
+    @InverseLogical("owner")
+    private ExtensionsEntity rel;
+
+    @ManyToOne
+    @JoinColumn(name = "OWNER_ID", referencedColumnName = "ID")
+    private ExtensionsEntity owner;
+
+    @ManyToMany
+    @LRS
+    private Collection<ExtensionsEntity> lrs;
+
+    @ManyToMany
+    @EagerFetchMode(FetchMode.JOIN)
+    @ElementClassCriteria
+    @ElementDependent
+    private Collection<ExtensionsEntity> eager;
+
+    @ExternalValues({ "M=1", "F=2" })
+    @Type(int.class)
+    private char externalValues;
+
+    @Persistent
+    @Externalizer("getName")
+    @Factory("Class.forName")
+    private Class externalizer;
+
+    public char getExternalValues() {
+        return this.externalValues;
+    }
+
+    public void setExternalValues(char externalValues) {
+        this.externalValues = externalValues;
+    }
+
+    public Class getExternalizer() {
+        return this.externalizer;
+    }
+
+    public void setExternalizer(Class externalizer) {
+        this.externalizer = externalizer;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/Flat1.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/Flat1.java?rev=590529&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/Flat1.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/Flat1.java Tue Oct 30 18:27:23 2007
@@ -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.annotations;
+
+
+import javax.persistence.*;
+
+@Entity(name="Flat1")
+@Table(name="Flat1")
+@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
+@DiscriminatorColumn(name = "EJB_CLS", length=100)
+public class Flat1 {
+
+    @Id
+    @Column(name = "PK")
+    protected int pk;
+
+    @Version
+    @Column(name = "EJB_VER")
+    protected int version;
+
+    @Basic
+    protected int basic;
+
+    public Flat1() {
+    }
+
+    public Flat1(int pk) {
+        this.pk = pk;
+    }
+
+    public void setPk(int val) {
+        pk = val;
+    }
+
+    public int getPk() {
+        return pk;
+    }
+
+    public int getVersion() {
+        return version;
+    }
+
+    public void setBasic(int i) {
+        basic = i;
+    }
+
+    public int getBasic() {
+        return basic;
+    }
+}
+

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/Flat2.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/Flat2.java?rev=590529&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/Flat2.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/Flat2.java Tue Oct 30 18:27:23 2007
@@ -0,0 +1,46 @@
+/*
+ * 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.annotations;
+
+
+import javax.persistence.*;
+
+@Entity(name="Flat2")
+public class Flat2
+    extends Flat1 {
+
+    @Basic
+    protected String basic2;
+
+    public Flat2() {
+    }
+
+    public Flat2(int pk) {
+        super(pk);
+    }
+
+    public void setBasic2(String s) {
+        basic2 = s;
+    }
+
+    public String getBasic2() {
+        return basic2;
+    }
+}
+

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/Generator.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/Generator.java?rev=590529&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/Generator.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/Generator.java Tue Oct 30 18:27:23 2007
@@ -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.persistence.jdbc.annotations;
+
+
+import java.util.*;
+
+import javax.persistence.*;
+
+@Entity
+// non-psql/ora dbs cause issues with SequenceGenerator in auto-mapping
+//@SequenceGenerator(name="seq", sequenceName="ejb_sequence")
+@TableGenerator(name = "tab")
+@IdClass(Generator.Oid.class)
+public class Generator {
+
+    @Id
+    protected int pk;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.TABLE, generator = "tab")
+    protected Integer pk2;
+
+    @Id
+    @GeneratedValue
+    protected long pk3;
+
+    @Basic
+    protected String stringField;
+
+    // for non-seq
+    public void setPk(int pk) {
+        this.pk = pk;
+    }
+
+    public int getPk() {
+        return pk;
+    }
+
+    public Integer getPk2() {
+        return pk2;
+    }
+
+    public long getPk3() {
+        return pk3;
+    }
+
+    public String getStringField() {
+        return stringField;
+    }
+
+    public void setStringField(String s) {
+        stringField = s;
+    }
+
+    public static class Oid {
+
+        public int pk;
+        public Integer pk2;
+        public long pk3;
+
+        public Oid() {
+        }
+
+        public Oid(String str) {
+            StringTokenizer tok = new StringTokenizer(str, ",");
+            pk = Integer.parseInt(tok.nextToken());
+            pk2 = Integer.valueOf(tok.nextToken());
+            pk3 = Long.valueOf(tok.nextToken());
+        }
+
+        public boolean equals(Object o) {
+            if (o == null || !(o instanceof Oid))
+                return false;
+            Oid other = (Oid) o;
+            if (pk != other.pk)
+                return false;
+            if (pk3 != other.pk3)
+                return false;
+            if (pk2 == null)
+                return other.pk2 == null;
+            return pk2.equals(other.pk2);
+        }
+
+        public int hashCode() {
+            return pk + (pk2 == null ? 0 : pk2.hashCode())
+                + (int) (pk3 % Integer.MAX_VALUE);
+        }
+
+        public String toString() {
+            return pk + "," + pk2 + "," + pk3;
+        }
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/PropertyAccess1.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/PropertyAccess1.java?rev=590529&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/PropertyAccess1.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/PropertyAccess1.java Tue Oct 30 18:27:23 2007
@@ -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.annotations;
+
+
+import javax.persistence.*;
+
+/**
+ * Entity test object that uses property access mode.
+ */
+@Entity
+public class PropertyAccess1 {
+
+    private int id;
+    private String name;
+    private int intVal; // this intentionally does not match the getter name
+
+    protected PropertyAccess1() {
+    }
+
+    public PropertyAccess1(int id) {
+        this.id = id;
+    }
+
+    @Id
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String n) {
+        this.name = n;
+    }
+
+    public int getIntValue() {
+        return intVal;
+    }
+
+    public void setIntValue(int intVal) {
+        this.intVal = intVal;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TablePerClass1.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TablePerClass1.java?rev=590529&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TablePerClass1.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TablePerClass1.java Tue Oct 30 18:27:23 2007
@@ -0,0 +1,64 @@
+/*
+ * 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.annotations;
+
+
+import javax.persistence.*;
+
+@Entity
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+public class TablePerClass1 {
+
+    @Id
+    @GeneratedValue
+    protected int pk;
+
+    @Column(name = "TPC_BASIC")
+    protected int basic;
+
+    @Embedded
+    @AttributeOverrides({
+    @AttributeOverride(name = "basic",
+        column = @Column(name = "TPC_EMB_BASIC")),
+    @AttributeOverride(name = "clob", column = @Column(name = "TPC_EMB_CLOB")),
+    @AttributeOverride(name = "blob", column = @Column(name = "TPC_EMB_BLOB"))
+        })
+    protected EmbedValue embed;
+
+    public int getPk() {
+        return pk;
+    }
+
+    public void setBasic(int i) {
+        basic = i;
+    }
+
+    public int getBasic() {
+        return basic;
+    }
+
+    public EmbedValue getEmbed() {
+        return embed;
+    }
+
+    public void setEmbed(EmbedValue ev) {
+        embed = ev;
+    }
+}
+

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TablePerClass2.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TablePerClass2.java?rev=590529&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TablePerClass2.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TablePerClass2.java Tue Oct 30 18:27:23 2007
@@ -0,0 +1,39 @@
+/*
+ * 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.annotations;
+
+
+import javax.persistence.*;
+
+@Entity
+public class TablePerClass2
+    extends TablePerClass1 {
+
+    @Basic
+    protected String basic2;
+
+    public void setBasic2(String s) {
+        basic2 = s;
+    }
+
+    public String getBasic2() {
+        return basic2;
+    }
+}
+

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestDiscriminator.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestDiscriminator.java?rev=590529&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestDiscriminator.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestDiscriminator.java Tue Oct 30 18:27:23 2007
@@ -0,0 +1,76 @@
+/*
+ * 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.annotations;
+
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
+import org.apache.openjpa.jdbc.meta.ClassMapping;
+import org.apache.openjpa.jdbc.meta.strats.NoneDiscriminatorStrategy;
+import org.apache.openjpa.jdbc.meta.strats.SubclassJoinDiscriminatorStrategy;
+import org.apache.openjpa.jdbc.meta.strats.ValueMapDiscriminatorStrategy;
+import org.apache.openjpa.jdbc.sql.JoinSyntaxes;
+import org.apache.openjpa.persistence.test.SingleEMFTestCase;
+
+/**
+ * <p>Test discriminator mappings.</p>
+ *
+ * @author Abe White
+ */
+public abstract class TestDiscriminator
+    extends SingleEMFTestCase {
+
+    public void setUp() {
+        //  #####
+//        setUp(Entity1.class, Entity2.class, AnnoTest1.class, CLEAR_TABLES);
+    }
+
+//    public void testNoDefaultJoinedDiscriminatorWithoutColumn() {
+//        JDBCConfiguration conf = (JDBCConfiguration) emf.getConfiguration();
+//        ClassMapping cls = conf.getMappingRepositoryInstance().
+//            getMapping(Entity1.class, null, true);
+//        if (conf.getDBDictionaryInstance().joinSyntax
+//            != JoinSyntaxes.SYNTAX_TRADITIONAL) {
+//            assertTrue(cls.getDiscriminator().getStrategy()
+//                instanceof SubclassJoinDiscriminatorStrategy);
+//        } else {
+//            assertEquals(NoneDiscriminatorStrategy.getInstance(),
+//                cls.getDiscriminator().getStrategy());
+//        }
+//        assertEquals(0, cls.getDiscriminator().getColumns().length);
+//    }
+
+    public void testJoinedDiscriminatorWithColumn() {
+        ClassMapping cls = ((JDBCConfiguration) emf.getConfiguration()).
+            getMappingRepositoryInstance().getMapping(AnnoTest1.class, 
+            null, true);
+        assertTrue(cls.getDiscriminator().getStrategy()
+            instanceof ValueMapDiscriminatorStrategy);
+        assertEquals(1, cls.getDiscriminator().getColumns().length);
+        assertEquals("ANNOCLS", cls.getDiscriminator().getColumns()[0].
+            getName());
+    }
+
+//    public void testDefaultFlatDiscriminator() {
+//        ClassMapping cls = ((JDBCConfiguration) emf.getConfiguration()).
+//            getMappingRepositoryInstance().getMapping(Entity2.class,
+//            null, true);
+//        assertTrue(cls.getDiscriminator().getStrategy()
+//            instanceof ValueMapDiscriminatorStrategy);
+//        assertEquals(1, cls.getDiscriminator().getColumns().length);
+//    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestEJBEmbedded.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestEJBEmbedded.java?rev=590529&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestEJBEmbedded.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestEJBEmbedded.java Tue Oct 30 18:27:23 2007
@@ -0,0 +1,127 @@
+/*
+ * 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.annotations;
+
+import java.sql.Types;
+import javax.persistence.EntityManager;
+
+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.meta.strats.ClobValueHandler;
+import org.apache.openjpa.jdbc.meta.strats.MaxEmbeddedClobFieldStrategy;
+import org.apache.openjpa.jdbc.meta.strats.StringFieldStrategy;
+import org.apache.openjpa.jdbc.sql.DBDictionary;
+import org.apache.openjpa.persistence.test.SingleEMFTestCase;
+
+/**
+ * Test for embedded
+ *
+ * @author Steve Kim
+ */
+public class TestEJBEmbedded extends SingleEMFTestCase {
+
+    private static final String CLOB;
+
+    static {
+        StringBuffer buf = new StringBuffer();
+        for (int i = 0; i < 1000; i++)
+            buf.append('a');
+        CLOB = buf.toString();
+    }
+
+    public void setUp() {
+        setUp(EmbedOwner.class, EmbedValue.class, CLEAR_TABLES);
+    }
+
+    public void testEmbedded() {
+        EntityManager em = emf.createEntityManager();
+        em.getTransaction().begin();
+        EmbedOwner owner = new EmbedOwner();
+        owner.setBasic("foo");
+        EmbedValue embed = new EmbedValue();
+        embed.setClob(CLOB);
+        embed.setBasic("bar");
+        embed.setBlob("foobar".getBytes());
+        embed.setOwner(owner);
+        owner.setEmbed(embed);
+        em.persist(owner);
+        int pk = owner.getPk();
+        em.getTransaction().commit();
+        em.close();
+
+        em = emf.createEntityManager();
+        owner = em.find(EmbedOwner.class, pk);
+        assertEquals("foo", owner.getBasic());
+        embed = owner.getEmbed();
+        assertNotNull(embed);
+        assertEquals(CLOB, embed.getClob());
+        assertEquals("bar", embed.getBasic());
+        assertEquals("foobar", new String(embed.getBlob()));
+        assertEquals(owner, embed.getOwner());
+        em.close();
+    }
+
+    public void testNull() {
+        EntityManager em = emf.createEntityManager();
+        em.getTransaction().begin();
+        EmbedOwner owner = new EmbedOwner();
+        owner.setBasic("foo");
+        em.persist(owner);
+        int pk = owner.getPk();
+        em.getTransaction().commit();
+        em.close();
+
+        em = emf.createEntityManager();
+        owner = em.find(EmbedOwner.class, pk);
+        assertEquals("foo", owner.getBasic());
+        EmbedValue embed = owner.getEmbed();
+        assertNotNull(embed);
+        assertNull(embed.getClob());
+        assertNull(embed.getBasic());
+        assertNull(embed.getBlob());
+        em.close();
+    }
+
+    public void testMappingTransferAndOverride() {
+        JDBCConfiguration conf = (JDBCConfiguration) emf.getConfiguration();
+        ClassMapping cls = conf.getMappingRepositoryInstance().getMapping
+            (EmbedOwner.class, null, true);
+        assertEquals("OWN_BASIC", cls.getFieldMapping("basic").
+            getColumns()[0].getName());
+        ClassMapping embed = cls.getFieldMapping("embed").getEmbeddedMapping();
+        assertEquals("EMB_BLOB", embed.getFieldMapping("blob").
+            getColumns()[0].getName());
+        assertEquals("OVER_BASIC", embed.getFieldMapping("basic").
+            getColumns()[0].getName());
+        assertEquals("OVER_OWNER", embed.getFieldMapping("owner").
+            getColumns()[0].getName());
+
+        FieldMapping fm = embed.getFieldMapping("clob");
+        DBDictionary dict = conf.getDBDictionaryInstance();
+        if (dict.getPreferredType(Types.CLOB) == Types.CLOB) {
+            if (dict.maxEmbeddedClobSize > 0)
+                assertTrue(fm.getStrategy() instanceof
+                    MaxEmbeddedClobFieldStrategy);
+            else
+                assertTrue(fm.getHandler() instanceof ClobValueHandler);
+        } else
+            assertTrue(fm.getStrategy() instanceof StringFieldStrategy);
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestEmbeddableSuperclass.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestEmbeddableSuperclass.java?rev=590529&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestEmbeddableSuperclass.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestEmbeddableSuperclass.java Tue Oct 30 18:27:23 2007
@@ -0,0 +1,136 @@
+/*
+ * 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.annotations;
+
+import java.sql.Types;
+
+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.meta.strats.ClobValueHandler;
+import org.apache.openjpa.jdbc.meta.strats.FullClassStrategy;
+import org.apache.openjpa.jdbc.meta.strats.MaxEmbeddedClobFieldStrategy;
+import org.apache.openjpa.jdbc.meta.strats.NoneClassStrategy;
+import org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy;
+import org.apache.openjpa.jdbc.meta.strats.StringFieldStrategy;
+import org.apache.openjpa.jdbc.sql.DBDictionary;
+import org.apache.openjpa.meta.ValueStrategies;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.test.SingleEMFTestCase;
+
+/**
+ * <p>Test embeddable superclasses.</p>
+ *
+ * @author Abe White
+ */
+public class TestEmbeddableSuperclass
+    extends SingleEMFTestCase {
+
+    public void setUp() {
+        setUp(EmbeddableSuper.class, EmbeddableSuperSub.class, CLEAR_TABLES);
+    }
+
+    public void testSuperclassEmbeddedOnly() {
+        ClassMapping cls = ((JDBCConfiguration) emf.getConfiguration()).
+            getMappingRepositoryInstance().getMapping(EmbeddableSuper.class, 
+            null, true);
+        assertTrue(cls.isEmbeddedOnly());
+        assertEquals(NoneClassStrategy.getInstance(), cls.getStrategy());
+    }
+
+    public void testSubclassMappingDefaultsAndOverrides() {
+        JDBCConfiguration conf = (JDBCConfiguration) emf.getConfiguration();
+        ClassMapping cls = conf.getMappingRepositoryInstance().
+            getMapping(EmbeddableSuperSub.class, null, true);
+        assertTrue(!cls.isEmbeddedOnly());
+        assertTrue(cls.getStrategy() instanceof FullClassStrategy);
+        assertEquals(ClassMapping.ID_APPLICATION, cls.getIdentityType());
+        assertTrue(cls.isOpenJPAIdentity());
+
+        FieldMapping fm = cls.getFieldMapping("pk");
+        assertTrue(fm.isPrimaryKey());
+        assertEquals(ValueStrategies.SEQUENCE, fm.getValueStrategy());
+        assertEquals("ID", fm.getColumns()[0].getName());
+
+        assertNull(cls.getField("trans"));
+
+        fm = cls.getFieldMapping("clob");
+        assertEquals("CC", fm.getColumns()[0].getName());
+        DBDictionary dict = conf.getDBDictionaryInstance();
+        if (dict.getPreferredType(Types.CLOB) == Types.CLOB) {
+            if (dict.maxEmbeddedClobSize > 0)
+                assertTrue(fm.getStrategy() instanceof
+                    MaxEmbeddedClobFieldStrategy);
+            else
+                assertTrue(fm.getHandler() instanceof ClobValueHandler);
+        } else
+            assertTrue(fm.getStrategy() instanceof StringFieldStrategy);
+    }
+
+    public void testSubclassDiscriminatorMapping() {
+        JDBCConfiguration conf = (JDBCConfiguration) emf.getConfiguration();
+        ClassMapping cls = conf.getMappingRepositoryInstance().
+            getMapping(EmbeddableSuperSub.class, null, true);
+        assertEquals("DISC", cls.getDiscriminator().getColumns()[0].
+            getName());
+    }
+
+    public void testVersionOverrideMapping() {
+        JDBCConfiguration conf = (JDBCConfiguration) emf.getConfiguration();
+        ClassMapping cls = conf.getMappingRepositoryInstance().
+            getMapping(EmbeddableSuperSub.class, null, true);
+        assertEquals("VERSVAL", cls.getVersion().getColumns()[0].getName());
+    }
+
+    public void testRelationMappings() {
+        JDBCConfiguration conf = (JDBCConfiguration) emf.getConfiguration();
+        ClassMapping cls = conf.getMappingRepositoryInstance().
+            getMapping(EmbeddableSuperSub.class, null, true);
+        FieldMapping fm = cls.getFieldMapping("sub");
+        assertTrue(fm.getStrategy() instanceof RelationFieldStrategy);
+
+        fm = cls.getFieldMapping("sup");
+        assertTrue(fm.getStrategy() instanceof RelationFieldStrategy);
+    }
+
+    public void testPersistAndFind() {
+        EmbeddableSuperSub parent = new EmbeddableSuperSub();
+        parent.setClob("parent");
+        EmbeddableSuperSub sub = new EmbeddableSuperSub();
+        sub.setClob("sub");
+        EmbeddableSuperSub sup = new EmbeddableSuperSub();
+        sup.setClob("sup");
+        parent.setSub(sub);
+        parent.setSup(sup);
+
+        OpenJPAEntityManager em = emf.createEntityManager();
+        em.getTransaction().begin();
+        em.persistAll(parent, sub, sup);
+        em.getTransaction().commit();
+        long pk = parent.getPK();
+        em.close();
+
+        em = emf.createEntityManager();
+        parent = em.find(EmbeddableSuperSub.class, pk);
+        assertEquals("parent", parent.getClob());
+        assertEquals("sub", parent.getSub().getClob());
+        assertEquals("sup", parent.getSup().getClob());
+        em.close();
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestEmbeddedId.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestEmbeddedId.java?rev=590529&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestEmbeddedId.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestEmbeddedId.java Tue Oct 30 18:27:23 2007
@@ -0,0 +1,244 @@
+/*
+ * 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.annotations;
+
+import javax.persistence.Query;
+
+import org.apache.openjpa.enhance.PersistenceCapable;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.test.SingleEMFTestCase;
+
+/**
+ * <p>Test embedded id classes.</p>
+ *
+ * @author Abe White
+ */
+public class TestEmbeddedId
+    extends SingleEMFTestCase {
+
+    EmbeddedIdClass _oid;
+    EmbeddedIdClass _roid;
+
+    public void setUp() {
+        setUp(EmbeddedIdEntity.class, EmbeddedIdClass.class, CLEAR_TABLES);
+
+        _oid = new EmbeddedIdClass();
+        _oid.setPk1(1);
+        _oid.setPk2(2);
+
+        EmbeddedIdEntity e = new EmbeddedIdEntity();
+        e.setId(_oid);
+        e.setValue("e");
+
+        _roid = new EmbeddedIdClass();
+        _roid.setPk1(2);
+        _roid.setPk2(3);
+
+        EmbeddedIdEntity rel = new EmbeddedIdEntity();
+        rel.setId(_roid);
+        rel.setValue("r");
+        e.setRelation(rel);
+
+        OpenJPAEntityManager em = emf.createEntityManager();
+        em.getTransaction().begin();
+        em.persistAll(e, rel);
+        em.getTransaction().commit();
+        em.close();
+    }
+
+    public void testGetObjectId() {
+        OpenJPAEntityManager em = emf.createEntityManager();
+        EmbeddedIdEntity e = em.find(EmbeddedIdEntity.class, _oid);
+        assertNotNull(e);
+        assertEquals("e", e.getValue());
+        assertNull(e.getMappingOverrideRelation());
+        assertNotNull(e.getRelation());
+        assertEquals("r", e.getRelation().getValue());
+
+        assertEquals(_oid, em.getObjectId(e));
+        assertEquals(_roid, em.getObjectId(e.getRelation()));
+        assertEquals(_oid, e.getId());
+        assertEquals(_roid, e.getRelation().getId());
+        assertNull(((PersistenceCapable) e.getId()).pcGetGenericContext());
+        em.close();
+    }
+
+    public void testMutateEmbeddedIdFieldValueOfNew() {
+        EmbeddedIdEntity e1 = new EmbeddedIdEntity();
+        e1.setValue("e1");
+        EmbeddedIdEntity e2 = new EmbeddedIdEntity();
+        e2.setValue("e2");
+        EmbeddedIdClass id = new EmbeddedIdClass();
+        e2.setId(id);
+
+        OpenJPAEntityManager em = emf.createEntityManager();
+        em.getTransaction().begin();
+        em.persistAll(e1, e2);
+
+        EmbeddedIdClass oid = new EmbeddedIdClass();
+        oid.setPk1(4);
+        oid.setPk2(5);
+        e1.setId(oid);
+        e2.getId().setPk1(6);
+        e2.getId().setPk2(7);
+        em.getTransaction().commit();
+
+        EmbeddedIdClass oid1 = e1.getId();
+        assertEquals(oid1, em.getObjectId(e1));
+        assertEquals(4, oid1.getPk1());
+        assertEquals(5, oid1.getPk2());
+
+        EmbeddedIdClass oid2 = e2.getId();
+        // pcl: 30 October 2007: this fails currently; commenting out.
+        // See OPENJPA-425
+        //assertEquals(oid2, em.getObjectId(e2));
+        assertEquals(6, oid2.getPk1());
+        assertEquals(7, oid2.getPk2());
+        em.close();
+
+        em = emf.createEntityManager();
+        e1 = em.find(EmbeddedIdEntity.class, oid1);
+        e2 = em.find(EmbeddedIdEntity.class, oid2);
+        assertEquals(oid1, em.getObjectId(e1));
+        assertEquals(oid2, em.getObjectId(e2));
+        assertEquals(oid1, e1.getId());
+        assertEquals(oid2, e2.getId());
+        em.close();
+    }
+
+    public void testMutateEmbeddedIdFieldValueOfExisting() {
+        OpenJPAEntityManager em = emf.createEntityManager();
+        em.getTransaction().begin();
+
+        EmbeddedIdEntity e = em.find(EmbeddedIdEntity.class, _oid);
+        e.setValue("changed");
+        try {
+            e.getId().setPk1(9);
+            em.getTransaction().commit();
+            fail("Committed with changed oid field.");
+        } catch (RuntimeException re) {
+            if (em.getTransaction().isActive())
+                em.getTransaction().rollback();
+        }
+        em.close();
+    }
+
+    public void testDetachAttach() {
+        OpenJPAEntityManager em = emf.createEntityManager();
+        EmbeddedIdEntity e = em.find(EmbeddedIdEntity.class, _oid);
+        e.getRelation();
+        em.close();
+
+        e.setValue("echanged");
+        e.getRelation().setValue("rchanged");
+
+        em = emf.createEntityManager();
+        em.getTransaction().begin();
+        EmbeddedIdEntity me = (EmbeddedIdEntity) em.mergeAll(e,
+            e.getRelation())[0];
+        assertTrue(me != e);
+        assertNotNull(me.getRelation());
+        assertTrue(me.getRelation() != e.getRelation());
+        assertEquals("echanged", me.getValue());
+        assertEquals("rchanged", me.getRelation().getValue());
+        assertEquals(_oid, me.getId());
+        assertEquals(_oid, em.getObjectId(me));
+        assertEquals(_roid, me.getRelation().getId());
+        assertEquals(_roid, em.getObjectId(me.getRelation()));
+        em.getTransaction().commit();
+        em.close();
+    }
+
+    public void testQuery() {
+        OpenJPAEntityManager em = emf.createEntityManager();
+        Query q = em.createQuery("select e from EmbeddedIdEntity e "
+            + "where e.id.pk1 = 1");
+        EmbeddedIdEntity e = (EmbeddedIdEntity) q.getSingleResult();
+        assertEquals(_oid, e.getId());
+        assertEquals("e", e.getValue());
+
+        q = em.createQuery("select e.id.pk2 from EmbeddedIdEntity e "
+            + "where e.id.pk1 = 1");
+        assertEquals(new Long(_oid.getPk2()), q.getSingleResult());
+
+        q = em.createQuery("select e.id from EmbeddedIdEntity e "
+            + "where e.id.pk1 = 1");
+        assertEquals(_oid, q.getSingleResult());
+        em.close();
+    }
+
+    public void testAutoAssigned() {
+        // begin with null id object
+        OpenJPAEntityManager em = emf.createEntityManager();
+        em.getTransaction().begin();
+        EmbeddedIdEntity e = new EmbeddedIdEntity();
+        em.persist(e);
+        EmbeddedIdClass oid = e.getId();
+        assertNotNull(oid);
+        assertTrue(oid.getPk3() != 0);
+        assertEquals(oid, em.getObjectId(e));
+        em.getTransaction().commit();
+        assertEquals(oid, em.getObjectId(e));
+        em.close();
+
+        em = emf.createEntityManager();
+        e = em.find(EmbeddedIdEntity.class, oid);
+        assertEquals(oid, em.getObjectId(e));
+        em.close();
+
+        // begin with non-null id object
+        em = emf.createEntityManager();
+        em.getTransaction().begin();
+        e = new EmbeddedIdEntity();
+        oid = new EmbeddedIdClass();
+        oid.setPk1(4);
+        oid.setPk2(5);
+        e.setId(oid);
+        em.persist(e);
+        oid = e.getId();
+        assertEquals(4, oid.getPk1());
+        assertEquals(5, oid.getPk2());
+        assertTrue(oid.getPk3() != 0);
+        assertEquals(oid, em.getObjectId(e));
+        em.getTransaction().commit();
+        assertEquals(oid, em.getObjectId(e));
+        em.close();
+
+        em = emf.createEntityManager();
+        e = em.find(EmbeddedIdEntity.class, oid);
+        assertEquals(oid, em.getObjectId(e));
+        em.close();
+
+        // flush before accessing id field
+        em = emf.createEntityManager();
+        em.getTransaction().begin();
+        e = new EmbeddedIdEntity();
+        em.persist(e);
+        em.getTransaction().commit();
+        oid = e.getId();
+        assertTrue(oid.getPk3() != 0);
+        assertEquals(oid, em.getObjectId(e));
+        em.close();
+
+        em = emf.createEntityManager();
+        e = em.find(EmbeddedIdEntity.class, oid);
+        assertEquals(oid, em.getObjectId(e));
+        em.close();
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestEnumerated.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestEnumerated.java?rev=590529&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestEnumerated.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestEnumerated.java Tue Oct 30 18:27:23 2007
@@ -0,0 +1,97 @@
+/*
+ * 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.annotations;
+
+import javax.persistence.InheritanceType;
+
+import org.apache.openjpa.jdbc.meta.ClassMapping;
+import org.apache.openjpa.jdbc.meta.FieldMapping;
+import org.apache.openjpa.meta.JavaTypes;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.test.SingleEMFTestCase;
+
+/**
+ * Test enums and the @Enumerated annotation.
+ *
+ * @author Abe White
+ */
+public class TestEnumerated
+    extends SingleEMFTestCase {
+
+    public void setUp() {
+        setUp(AnnoTest1.class, AnnoTest2.class, Flat1.class, CLEAR_TABLES);
+    }
+
+    public void testMapping() {
+        ClassMapping cls = (ClassMapping) emf.getConfiguration().
+            getMetaDataRepositoryInstance().getMetaData(AnnoTest1.class, 
+            null, true);
+        FieldMapping fm = cls.getDeclaredFieldMapping("enumeration");
+        assertNotNull(fm);
+        assertEquals(FieldMapping.MANAGE_PERSISTENT, fm.getManagement());
+        assertEquals(JavaTypes.OBJECT, fm.getTypeCode());
+        assertEquals(JavaTypes.SHORT, fm.getColumns()[0].getJavaType());
+
+        fm = cls.getDeclaredFieldMapping("ordinalEnumeration");
+        assertNotNull(fm);
+        assertEquals(FieldMapping.MANAGE_PERSISTENT, fm.getManagement());
+        assertEquals(JavaTypes.OBJECT, fm.getTypeCode());
+        assertEquals(JavaTypes.SHORT, fm.getColumns()[0].getJavaType());
+
+        fm = cls.getDeclaredFieldMapping("stringEnumeration");
+        assertNotNull(fm);
+        assertEquals(FieldMapping.MANAGE_PERSISTENT, fm.getManagement());
+        assertEquals(JavaTypes.OBJECT, fm.getTypeCode());
+        assertEquals(JavaTypes.STRING, fm.getColumns()[0].getJavaType());
+    }
+
+    public void testBehavior() {
+        OpenJPAEntityManager em = emf.createEntityManager();
+        em.getTransaction().begin();
+        AnnoTest1 pc = new AnnoTest1(1);
+        pc.setEnumeration(InheritanceType.TABLE_PER_CLASS);
+        pc.setOrdinalEnumeration(InheritanceType.TABLE_PER_CLASS);
+        pc.setStringEnumeration(InheritanceType.JOINED);
+        em.persist(pc);
+        em.getTransaction().commit();
+        em.close();
+
+        em = emf.createEntityManager();
+        pc = em.find(AnnoTest1.class, new Long(1));
+        assertEquals(InheritanceType.TABLE_PER_CLASS, pc.getEnumeration());
+        assertEquals(InheritanceType.TABLE_PER_CLASS,
+            pc.getOrdinalEnumeration());
+        assertEquals(InheritanceType.JOINED,
+            pc.getStringEnumeration());
+        em.getTransaction().begin();
+        pc.setEnumeration(InheritanceType.JOINED);
+        pc.setOrdinalEnumeration(InheritanceType.JOINED);
+        pc.setStringEnumeration(InheritanceType.TABLE_PER_CLASS);
+        em.getTransaction().commit();
+        em.close();
+
+        em = emf.createEntityManager();
+        pc = em.find(AnnoTest1.class, new Long(1));
+        assertEquals(InheritanceType.JOINED, pc.getEnumeration());
+        assertEquals(InheritanceType.JOINED, pc.getOrdinalEnumeration());
+        assertEquals(InheritanceType.TABLE_PER_CLASS,
+            pc.getStringEnumeration());
+        em.close();
+    }
+}



Mime
View raw message