Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 9731 invoked from network); 15 Feb 2008 09:24:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Feb 2008 09:24:53 -0000 Received: (qmail 26970 invoked by uid 500); 15 Feb 2008 09:24:47 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 26950 invoked by uid 500); 15 Feb 2008 09:24:47 -0000 Mailing-List: contact commits-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list commits@openjpa.apache.org Received: (qmail 26941 invoked by uid 99); 15 Feb 2008 09:24:47 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Feb 2008 01:24:47 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Feb 2008 09:24:01 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 912E21A9887; Fri, 15 Feb 2008 01:23:32 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r627979 [35/39] - in /openjpa/trunk: openjpa-lib/src/test/java/org/apache/openjpa/lib/test/ openjpa-persistence-jdbc/ openjpa-persistence-jdbc/src/test/java/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/ openjpa-per... Date: Fri, 15 Feb 2008 09:20:40 -0000 To: commits@openjpa.apache.org From: pcl@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080215092332.912E21A9887@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/PersistentMapHolder.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/PersistentMapHolder.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/PersistentMapHolder.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/PersistentMapHolder.java Fri Feb 15 01:19:55 2008 @@ -0,0 +1,118 @@ +/* + * 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.kernel.common.apps; + +import java.util.HashMap; +import java.util.Map; +import javax.persistence.CascadeType; +import javax.persistence.Entity; + +import org.apache.openjpa.persistence.jdbc.KeyColumn; +import org.apache.openjpa.persistence.PersistentMap; + +@Entity +public class PersistentMapHolder { + + @PersistentMap(keyCascade = CascadeType.PERSIST) + @KeyColumn(name = "testPCKeyStringValue") + private Map testPCKeyStringValue = + new HashMap(); + + @PersistentMap(elementCascade = CascadeType.PERSIST) + @KeyColumn(name = "testStringKeyPCValue") + private Map testStringKeyPCValue = + new HashMap(); + + @PersistentMap(keyCascade = CascadeType.PERSIST, + elementCascade = CascadeType.PERSIST) + @KeyColumn(name = "testPCKeyPCValue") + private Map testPCKeyPCValue = + new HashMap(); + + @PersistentMap(keyCascade = CascadeType.PERSIST) + @KeyColumn(name = "testPCSubKeyStringValue") + private Map testPCSubKeyStringValue = + new HashMap(); + + @PersistentMap(elementCascade = CascadeType.PERSIST) + @KeyColumn(name = "testStringKeyPCSubValue") + private Map testStringKeyPCSubValue = + new HashMap(); + + @PersistentMap(keyCascade = CascadeType.PERSIST, + elementCascade = CascadeType.PERSIST) + @KeyColumn(name = "testPCSubKeyPCValue") + private Map testPCSubKeyPCValue = + new HashMap(); + + @PersistentMap(keyCascade = CascadeType.PERSIST, + elementCascade = CascadeType.PERSIST) + @KeyColumn(name = "testPCSubKeyPCSubValue") + private Map testPCSubKeyPCSubValue = + new HashMap(); + + @PersistentMap(keyCascade = CascadeType.PERSIST, + elementCascade = CascadeType.PERSIST) + @KeyColumn(name = "testPCKeyPCSubValue") + private Map testPCKeyPCSubValue = + new HashMap(); + + @PersistentMap(keyCascade = CascadeType.PERSIST) + @KeyColumn(name = "testPCIntfKeyStringValue") + private Map testPCIntfKeyStringValue = + new HashMap(); + + @PersistentMap(elementCascade = CascadeType.PERSIST) + @KeyColumn(name = "testStringKeyPCIntfValue") + private Map testStringKeyPCIntfValue = + new HashMap(); + + @PersistentMap(keyCascade = CascadeType.PERSIST, + elementCascade = CascadeType.PERSIST) + @KeyColumn(name = "testPCIntfKeyPCValue") + private Map testPCIntfKeyPCValue = + new HashMap(); + + public Map getNamedMap(String name) { + if (name.equals("testPCKeyStringValue")) + return testPCKeyStringValue; + if (name.equals("testStringKeyPCValue")) + return testStringKeyPCValue; + if (name.equals("testPCKeyPCValue")) + return testPCKeyPCValue; + if (name.equals("testPCSubKeyStringValue")) + return testPCSubKeyStringValue; + if (name.equals("testStringKeyPCSubValue")) + return testStringKeyPCSubValue; + if (name.equals("testPCSubKeyPCValue")) + return testPCSubKeyPCValue; + if (name.equals("testPCSubKeyPCSubValue")) + return testPCSubKeyPCSubValue; + if (name.equals("testPCKeyPCSubValue")) + return testPCKeyPCSubValue; + if (name.equals("testPCIntfKeyStringValue")) + return testPCIntfKeyStringValue; + if (name.equals("testStringKeyPCIntfValue")) + return testStringKeyPCIntfValue; + if (name.equals("testPCIntfKeyPCValue")) + return testPCIntfKeyPCValue; + + return null; + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/ProxiesPC.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/ProxiesPC.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/ProxiesPC.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/ProxiesPC.java Fri Feb 15 01:19:55 2008 @@ -0,0 +1,179 @@ +/* + * 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.kernel.common.apps; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.openjpa.persistence.jdbc.KeyColumn; +import org.apache.commons.collections.comparators.ComparableComparator; +import org.apache.openjpa.persistence.PersistentCollection; +import org.apache.openjpa.persistence.PersistentMap; + +/** + *

Persistent type used in the {@link TestProxies} tests.

+ * + * @author Abe White + */ +@Entity +@Table(name = "PROX_PC") +public class ProxiesPC implements Comparable { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + public int id; + + private String name = null; + + @PersistentCollection + private Set stringSet = new HashSet(); + + @OneToMany(cascade = { CascadeType.PERSIST, CascadeType.REMOVE }) + private TreeSet proxySet = new TreeSet(); + + @PersistentMap + @KeyColumn(name = "strngkey") + private Map stringMap = new HashMap(); + + // @PersistentMap + @OneToMany(cascade = { CascadeType.PERSIST, CascadeType.REMOVE }) + @KeyColumn(name = "prxykey") + private TreeMap proxyMap = new TreeMap(); + + @PersistentCollection + private List list = new ArrayList(); + + @PersistentCollection + private Collection comp = new TreeSet(new ComparableComparator()); + + @Temporal(TemporalType.DATE) + private Date date = null; + + // sql types + private java.sql.Date sqlDate = null; + private java.sql.Timestamp timestamp = null; + + public ProxiesPC() { + } + + public ProxiesPC(String name) { + this.name = name; + } + + public int getId() { + return this.id; + } + + public String getName() { + return name; + } + + public Set getStringSet() { + return stringSet; + } + + public void setStringSet(Set stringSet) { + this.stringSet = stringSet; + } + + public TreeSet getProxySet() { + return proxySet; + } + + public void setProxySet(TreeSet proxySet) { + this.proxySet = proxySet; + } + + public Map getStringMap() { + return stringMap; + } + + public void setStringMap(Map stringMap) { + this.stringMap = stringMap; + } + + public TreeMap getProxyMap() { + return proxyMap; + } + + public void setProxyMap(TreeMap proxyMap) { + this.proxyMap = proxyMap; + } + + public int compareTo(Object other) { + return name.compareTo(((ProxiesPC) other).getName()); + } + + public List getList() { + return this.list; + } + + public void setList(List list) { + this.list = list; + } + + public Collection getComp() { + return this.comp; + } + + public void setComp(Collection comp) { + this.comp = comp; + } + + public java.sql.Date getSQLDate() { + return this.sqlDate; + } + + public void setSQLDate(java.sql.Date sqlDate) { + this.sqlDate = sqlDate; + } + + public java.sql.Timestamp getTimestamp() { + return this.timestamp; + } + + public void setTimestamp(java.sql.Timestamp timestamp) { + this.timestamp = timestamp; + } + + public Date getDate() { + return this.date; + } + + public void setDate(Date date) { + this.date = date; + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RecursivelyEmbeddedPC.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RecursivelyEmbeddedPC.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RecursivelyEmbeddedPC.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RecursivelyEmbeddedPC.java Fri Feb 15 01:19:55 2008 @@ -0,0 +1,45 @@ +/* + * 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.kernel.common.apps; + +import javax.persistence.Entity; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.OneToOne; + +/** + *

Embedded type used in testing.

+ * + * @author Abe White + */ +@Entity +@Inheritance(strategy = InheritanceType.SINGLE_TABLE) +public class RecursivelyEmbeddedPC { + + @OneToOne + private EmbeddedPC embedded; + + public EmbeddedPC getEmbedded() { + return this.embedded; + } + + public void setEmbedded(EmbeddedPC embedded) { + this.embedded = embedded; + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RuntimeTest1.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RuntimeTest1.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RuntimeTest1.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RuntimeTest1.java Fri Feb 15 01:19:55 2008 @@ -0,0 +1,158 @@ +/* + * 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.kernel.common.apps; + +import java.io.Serializable; +import java.util.Date; +import java.util.HashSet; +import java.util.Locale; +import java.util.Set; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.OneToMany; +import javax.persistence.OneToOne; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; +import javax.persistence.Version; + +/** + *

Persitent type used in testing.

+ * + * @author Abe White + */ +@Entity +@Table(name = "rtest1") +@Inheritance(strategy = InheritanceType.SINGLE_TABLE) +public class RuntimeTest1 implements Serializable { + + private static final long serialVersionUID = 1L; + + @Temporal(TemporalType.DATE) + private Date dateField; + + @Transient + public static final String someStaticField = "someField"; + + private Locale localeField; + + @Id + private int intField; + + private int intField1; + + @Column(length = 35) + private String stringField; + + // transactional only + @Column(length = 35) + public String transString; + + // relations + //@Transient + @OneToOne(fetch = FetchType.LAZY, + cascade = { CascadeType.PERSIST, CascadeType.REMOVE }) + private RuntimeTest1 selfOneOne; + + @OneToMany(mappedBy = "selfOneOne", + cascade = { CascadeType.PERSIST, CascadeType.REMOVE }) + private Set selfOneMany = new HashSet(); + + @Version + private int version; + + public RuntimeTest1() { + } + + public RuntimeTest1(int key) { + this.intField = key; + } + + public RuntimeTest1(String str, int i) { + stringField = str; + intField = i; + intField1 = i; + } + + public int getIntField() { + return this.intField; + } + + public int getIntField1() { + return this.intField1; + } + + public void setIntField(int intField) { + this.intField = intField; + } + + public void setIntField1(int intField1) { + this.intField1 = intField1; + } + + public String getStringField() { + return this.stringField; + } + + public void setStringField(String stringField) { + this.stringField = stringField; + } + + public RuntimeTest1 getSelfOneOne() { + return this.selfOneOne; + } + + public void setSelfOneOne(RuntimeTest1 selfOneOne) { + this.selfOneOne = selfOneOne; + } + + public Set getSelfOneMany() { + return this.selfOneMany; + } + + public void setSelfOneMany(Set selfOneMany) { + this.selfOneMany = selfOneMany; + } + + public String toString() { + return "IntField: " + intField + ", StringField: " + stringField + " ."; + } + + public Locale getLocaleField() { + return localeField; + } + + public void setLocaleField(Locale localeField) { + this.localeField = localeField; + } + + public Date getDateField() { + return this.dateField; + } + + public void setDateField(Date d) { + this.dateField = d; + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RuntimeTest2.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RuntimeTest2.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RuntimeTest2.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RuntimeTest2.java Fri Feb 15 01:19:55 2008 @@ -0,0 +1,60 @@ +/* + * 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.kernel.common.apps; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +/** + *

Persitent type used in testing.

+ * + * @author Abe White + */ +@Entity +@DiscriminatorValue("RT2") +public class RuntimeTest2 extends RuntimeTest1 { + + private static final long serialVersionUID = 1L; + //@Id + private int intField2; + + public RuntimeTest2() { + } + + public RuntimeTest2(int key) { + super(key); + } + + public RuntimeTest2(String str, int i) { + super(str, i); + } + + public int getIntField2() { + return this.intField2; + } + + public void setIntField2(int intField2) { + this.intField2 = intField2; + } + + public String toString() { + return "IntField: " + intField2 + ", StringField: " + + super.getStringField() + " ."; + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RuntimeTest3.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RuntimeTest3.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RuntimeTest3.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RuntimeTest3.java Fri Feb 15 01:19:55 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.persistence.kernel.common.apps; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +/** + *

Persitent type used in testing.

+ * + * @author Abe White + */ +@Entity +@DiscriminatorValue("RT3") +public class RuntimeTest3 + extends RuntimeTest2 { + + //@Id + private int intField3; + + public RuntimeTest3() { + } + + public RuntimeTest3(String str, int i) { + super(str, i); + } + + public int getIntField3() { + return this.intField3; + } + + public void setIntField3(int intField3) { + this.intField3 = intField3; + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RuntimeTest4.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RuntimeTest4.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RuntimeTest4.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RuntimeTest4.java Fri Feb 15 01:19:55 2008 @@ -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.kernel.common.apps; + +import java.util.ArrayList; +import java.util.Collection; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.OneToMany; + +@Entity +public class RuntimeTest4 { + + private String name; + + @OneToMany(cascade = { CascadeType.PERSIST, CascadeType.REMOVE }) + private Collection runtimeTest5s = new ArrayList(); + + public RuntimeTest4(String str) { + name = str; + } + + public void setName(String val) { + name = val; + } + + public String getName() { + return name; + } + + public Collection getRuntimeTest5s() { + return runtimeTest5s; + } + + public void setRuntimeTest5s(Collection c) { + runtimeTest5s = c; + } +} \ No newline at end of file Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RuntimeTest5.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RuntimeTest5.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RuntimeTest5.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/RuntimeTest5.java Fri Feb 15 01:19:55 2008 @@ -0,0 +1,48 @@ +/* + * 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.kernel.common.apps; + +import javax.persistence.Entity; + +@Entity +public class RuntimeTest5 { + + private String name; + private RuntimeTest4 runtimeTest4; + + public RuntimeTest5(String str) { + name = str; + } + + public void setName(String val) { + name = val; + } + + public String getName() { + return name; + } + + public void setRuntimeTest4(RuntimeTest4 val) { + runtimeTest4 = val; + } + + public RuntimeTest4 getRuntimeTest4() { + return runtimeTest4; + } +} \ No newline at end of file Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SCOTest.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SCOTest.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SCOTest.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SCOTest.java Fri Feb 15 01:19:55 2008 @@ -0,0 +1,291 @@ +/* + * 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.kernel.common.apps; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Collection; +import java.util.Date; +import java.util.Map; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +import org.apache.openjpa.persistence.jdbc.KeyColumn; +import org.apache.openjpa.persistence.PersistentCollection; +import org.apache.openjpa.persistence.PersistentMap; + +/** + * Used in testing; should be enhanced. + */ +@Entity +public class SCOTest { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + @PersistentMap + @KeyColumn(name = "strintkey") + private Map strIntMap; + + @PersistentMap + @KeyColumn(name = "intlngkey") + private Map intLongMap; + + @PersistentMap + @KeyColumn(name = "lngfltkey") + private Map longFloatMap; + + @PersistentMap + @KeyColumn(name = "fltbtekey") + private Map floatByteMap; + + @PersistentMap + @KeyColumn(name = "btedbkey") + private Map byteDoubleMap; + + @PersistentMap + @KeyColumn(name = "dbchkey") + private Map doubleCharMap; + + @PersistentMap + @KeyColumn(name = "chblkey") + private Map charBooleanMap; + + @PersistentMap + @KeyColumn(name = "dtstrkey") + private Map dateStrMap; + + @PersistentMap + @KeyColumn(name = "bgdckey") + private Map bigDecimalBigIntegerMap; + + @PersistentCollection + private Collection cString; + + @PersistentCollection + private Collection cInteger; + + @PersistentCollection + private Collection cLong; + + @PersistentCollection + private Collection cFloat; + + @PersistentCollection + private Collection cByte; + + @PersistentCollection + private Collection cDouble; + + @PersistentCollection + private Collection cBoolean; + + @PersistentCollection + private Collection cShort; + + @PersistentCollection + private Collection cDate; + + @PersistentCollection + private Collection cCharacter; + + @PersistentCollection + private Collection cBigInteger; + + @PersistentCollection + private Collection cBigDecimal; + + public SCOTest() { + } + + public int getId() { + return this.id; + } + + public void setBigDecimalBigIntegerMap(Map bigDecimalBigIntegerMap) { + this.bigDecimalBigIntegerMap = bigDecimalBigIntegerMap; + } + + public Map getBigDecimalBigIntegerMap() { + return bigDecimalBigIntegerMap; + } + + public void setStrIntMap(Map strIntMap) { + this.strIntMap = strIntMap; + } + + public Map getStrIntMap() { + return strIntMap; + } + + public void setIntLongMap(Map intLongMap) { + this.intLongMap = intLongMap; + } + + public Map getIntLongMap() { + return intLongMap; + } + + public void setLongFloatMap(Map longFloatMap) { + this.longFloatMap = longFloatMap; + } + + public Map getLongFloatMap() { + return longFloatMap; + } + + public void setFloatByteMap(Map floatByteMap) { + this.floatByteMap = floatByteMap; + } + + public Map getFloatByteMap() { + return floatByteMap; + } + + public void setByteDoubleMap(Map byteDoubleMap) { + this.byteDoubleMap = byteDoubleMap; + } + + public Map getByteDoubleMap() { + return byteDoubleMap; + } + + public void setDoubleCharMap(Map doubleCharMap) { + this.doubleCharMap = doubleCharMap; + } + + public Map getDoubleCharMap() { + return doubleCharMap; + } + + public void setCharBooleanMap(Map charBooleanMap) { + this.charBooleanMap = charBooleanMap; + } + + public Map getCharBooleanMap() { + return charBooleanMap; + } + + public void setDateStrMap(Map dateStrMap) { + this.dateStrMap = dateStrMap; + } + + public Map getDateStrMap() { + return dateStrMap; + } + + public void setCString(Collection cString) { + this.cString = cString; + } + + public Collection getCString() { + return cString; + } + + public void setCInteger(Collection cInteger) { + this.cInteger = cInteger; + } + + public Collection getCInteger() { + return cInteger; + } + + public void setCLong(Collection cLong) { + this.cLong = cLong; + } + + public Collection getCLong() { + return cLong; + } + + public void setCCharacter(Collection cCharacter) { + this.cCharacter = cCharacter; + } + + public Collection getCCharacter() { + return cCharacter; + } + + public void setCFloat(Collection cFloat) { + this.cFloat = cFloat; + } + + public Collection getCFloat() { + return cFloat; + } + + public void setCByte(Collection cByte) { + this.cByte = cByte; + } + + public Collection getCByte() { + return cByte; + } + + public void setCDouble(Collection cDouble) { + this.cDouble = cDouble; + } + + public Collection getCDouble() { + return cDouble; + } + + public void setCBoolean(Collection cBoolean) { + this.cBoolean = cBoolean; + } + + public Collection getCBoolean() { + return cBoolean; + } + + public void setCShort(Collection cShort) { + this.cShort = cShort; + } + + public Collection getCShort() { + return cShort; + } + + public void setCDate(Collection cDate) { + this.cDate = cDate; + } + + public Collection getCDate() { + return cDate; + } + + public void setCBigInteger(Collection cBigInteger) { + this.cBigInteger = cBigInteger; + } + + public Collection getCBigInteger() { + return cBigInteger; + } + + public void setCBigDecimal(Collection cBigDecimal) { + this.cBigDecimal = cBigDecimal; + } + + public Collection getCBigDecimal() { + return cBigDecimal; + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SecondaryTab.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SecondaryTab.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SecondaryTab.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SecondaryTab.java Fri Feb 15 01:19:55 2008 @@ -0,0 +1,66 @@ +/* + * 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.kernel.common.apps; + +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.SecondaryTable; +import javax.persistence.SecondaryTables; +import javax.persistence.Table; + +@Entity +@Table(name = "sectables") +@SecondaryTables({ +@SecondaryTable(name = "SEC1_TAB"), +@SecondaryTable(name = "SEC2_TAB") + }) +public class SecondaryTab { + + @Id + public int id; + + @Basic + @Column(name = "strngfld", length = 50) + public String stringField; + + public SecondaryTab() { + } + + public SecondaryTab(int id) { + this.id = id; + } + + public int getid() { + return id; + } + + public void setid(int id) { + this.id = id; + } + + public String getStringField() { + return stringField; + } + + public void setStringField(String stringField) { + this.stringField = stringField; + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SequenceAssigned.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SequenceAssigned.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SequenceAssigned.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SequenceAssigned.java Fri Feb 15 01:19:55 2008 @@ -0,0 +1,91 @@ +/* + * 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.kernel.common.apps; + +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.OneToOne; +import javax.persistence.Table; + +@Entity +@Table(name = "seqAssigned") +@Inheritance(strategy = InheritanceType.SINGLE_TABLE) +@IdClass(SequenceAssigned.SeqId.class) +public class SequenceAssigned { + + @Id + private long pk; + + @OneToOne(cascade = { CascadeType.PERSIST, CascadeType.REMOVE }) + private SequenceAssigned other; + + public SequenceAssigned() { + } + + public SequenceAssigned(long pk) { + this.pk = pk; + } + + public void setPK(long l) { + pk = l; + } + + public long getPK() { + return pk; + } + + public void setOther(SequenceAssigned other) { + this.other = other; + } + + public SequenceAssigned getOther() { + return other; + } + + @SuppressWarnings("serial") + public static class SeqId implements java.io.Serializable { + + public long pk; + + public SeqId() { + } + + public SeqId(String str) { + pk = Long.parseLong(str); + } + + public int hashCode() { + return (int) (pk % (long) Integer.MAX_VALUE); + } + + public String toString() { + return pk + ""; + } + + public boolean equals(Object o) { + if (o == null || !(o instanceof SeqId)) + return false; + return pk == ((SeqId) o).pk; + } + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SequenceAssigned2.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SequenceAssigned2.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SequenceAssigned2.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SequenceAssigned2.java Fri Feb 15 01:19:55 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.persistence.kernel.common.apps; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +@Entity +@DiscriminatorValue("seqAss2") +public class SequenceAssigned2 extends SequenceAssigned { + + private int foo; + + public SequenceAssigned2(long pk) { + super(pk); + } + + public int getFoo() { + return foo; + } + + public void setFoo(int foo) { + this.foo = foo; + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SequenceAssigned3.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SequenceAssigned3.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SequenceAssigned3.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SequenceAssigned3.java Fri Feb 15 01:19:55 2008 @@ -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.kernel.common.apps; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.Table; + +@Entity +@Table(name = "seqAss3") +@IdClass(SequenceAssigned3.seq3Id.class) +public class SequenceAssigned3 { + + @Id + private Long pk; + + public SequenceAssigned3() { + } + + public SequenceAssigned3(Long pk) { + this.pk = pk; + } + + public void setPK(Long l) { + pk = l; + } + + public Long getPK() { + return pk; + } + + @SuppressWarnings("serial") + public static class seq3Id implements java.io.Serializable { + + public Long pk; + + public seq3Id() { + } + + public seq3Id(String str) { + pk = Long.valueOf(str); + } + + public int hashCode() { + return (int) (pk == null ? 0 : pk.longValue() + % (long) Integer.MAX_VALUE); + } + + public String toString() { + return pk + ""; + } + + public boolean equals(Object o) { + if (o == null || !(o instanceof seq3Id)) + return false; + return pk == ((seq3Id) o).pk; + } + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleId.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleId.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleId.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleId.java Fri Feb 15 01:19:55 2008 @@ -0,0 +1,30 @@ +/* + * 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.kernel.common.apps; + +public interface SingleId { + + public String getPkString(); + + public void setString(String s); + + public String getString(); + + public boolean correctIdClass(Class oid); +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdByte.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdByte.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdByte.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdByte.java Fri Feb 15 01:19:55 2008 @@ -0,0 +1,56 @@ +/* + * 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.kernel.common.apps; + + + +import javax.persistence.Entity; + +import org.apache.openjpa.util.ByteId; + +@Entity +public class SingleIdByte implements SingleId { + + private byte pk; + private String str; + + public boolean correctIdClass(Class c) { + return ByteId.class.equals(c); + } + + public byte getPk() { + return pk; + } + + public void setPk(byte i) { + pk = i; + } + + public String getPkString() { + return pk + ""; + } + + public String getString() { + return str; + } + + public void setString(String s) { + str = s; + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdChar.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdChar.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdChar.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdChar.java Fri Feb 15 01:19:55 2008 @@ -0,0 +1,56 @@ +/* + * 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.kernel.common.apps; + + + +import javax.persistence.Entity; + +import org.apache.openjpa.util.CharId; + +@Entity +public class SingleIdChar implements SingleId { + + private char pk; + private String str; + + public boolean correctIdClass(Class c) { + return CharId.class.equals(c); + } + + public char getPk() { + return pk; + } + + public String getPkString() { + return pk + ""; + } + + public void setPk(char i) { + pk = i; + } + + public String getString() { + return str; + } + + public void setString(String s) { + str = s; + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdInt.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdInt.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdInt.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdInt.java Fri Feb 15 01:19:55 2008 @@ -0,0 +1,56 @@ +/* + * 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.kernel.common.apps; + + + +import javax.persistence.Entity; + +import org.apache.openjpa.util.IntId; + +@Entity +public class SingleIdInt implements SingleId { + + private int pk; + private String str; + + public boolean correctIdClass(Class c) { + return IntId.class.equals(c); + } + + public String getPkString() { + return pk + ""; + } + + public int getPk() { + return pk; + } + + public void setPk(int i) { + pk = i; + } + + public String getString() { + return str; + } + + public void setString(String s) { + str = s; + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdLong.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdLong.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdLong.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdLong.java Fri Feb 15 01:19:55 2008 @@ -0,0 +1,56 @@ +/* + * 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.kernel.common.apps; + + + +import javax.persistence.Entity; + +import org.apache.openjpa.util.LongId; + +@Entity +public class SingleIdLong implements SingleId { + + private long pk; + private String str; + + public boolean correctIdClass(Class c) { + return LongId.class.equals(c); + } + + public String getPkString() { + return pk + ""; + } + + public long getPk() { + return pk; + } + + public void setPk(long i) { + pk = i; + } + + public String getString() { + return str; + } + + public void setString(String s) { + str = s; + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdShort.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdShort.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdShort.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdShort.java Fri Feb 15 01:19:55 2008 @@ -0,0 +1,56 @@ +/* + * 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.kernel.common.apps; + + + +import javax.persistence.Entity; + +import org.apache.openjpa.util.ShortId; + +@Entity +public class SingleIdShort implements SingleId { + + private short pk; + private String str; + + public boolean correctIdClass(Class c) { + return ShortId.class.equals(c); + } + + public String getPkString() { + return pk + ""; + } + + public short getPk() { + return pk; + } + + public void setPk(short i) { + pk = i; + } + + public String getString() { + return str; + } + + public void setString(String s) { + str = s; + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdString.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdString.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdString.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdString.java Fri Feb 15 01:19:55 2008 @@ -0,0 +1,56 @@ +/* + * 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.kernel.common.apps; + + + +import javax.persistence.Entity; + +import org.apache.openjpa.util.StringId; + +@Entity +public class SingleIdString implements SingleId { + + private String pk; + private String str; + + public boolean correctIdClass(Class c) { + return StringId.class.equals(c); + } + + public String getPk() { + return pk; + } + + public String getPkString() { + return pk; + } + + public void setPk(String i) { + pk = i; + } + + public String getString() { + return str; + } + + public void setString(String s) { + str = s; + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdWrapper.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdWrapper.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdWrapper.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/SingleIdWrapper.java Fri Feb 15 01:19:55 2008 @@ -0,0 +1,60 @@ +/* + * 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.kernel.common.apps; + + + +import javax.persistence.Entity; + +import org.apache.openjpa.util.IntId; + +@Entity +public class SingleIdWrapper implements SingleId { + + private Integer pk; + private String str; + + public boolean correctIdClass(Class c) { + return IntId.class.equals(c); + } + + public String getPkString() { + return pk == null ? "null" : pk.toString(); + } + + public int getPk() { + return pk.intValue(); + } + + public void setPk(int i) { + pk = new Integer(i); + } + + public String getString() { + return str; + } + + public void setString(String s) { + str = s; + } + + public static void main(String[] args) { + SingleIdWrapper wrap = new SingleIdWrapper(); + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/TransactionalClassPC.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/TransactionalClassPC.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/TransactionalClassPC.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/TransactionalClassPC.java Fri Feb 15 01:19:55 2008 @@ -0,0 +1,37 @@ +/* + * 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.kernel.common.apps; + +/** + *

Transactional type used in testing.

+ * + * @author Abe White + */ +public class TransactionalClassPC { + + private int intField; + + public int getIntField() { + return this.intField; + } + + public void setIntField(int intField) { + this.intField = intField; + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/UnAnnotPojo.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/UnAnnotPojo.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/UnAnnotPojo.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/UnAnnotPojo.java Fri Feb 15 01:19:55 2008 @@ -0,0 +1,53 @@ +/* + * 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.kernel.common.apps; + +/** + *

Pojo type used in testing.

+ * + * @author Afam Okeke + */ +public class UnAnnotPojo { + + private String name; + private int num; + + public UnAnnotPojo() { + } + + public UnAnnotPojo(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getNum() { + return num; + } + + public void setNum(int num) { + this.num = num; + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/ValueStrategyPC.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/ValueStrategyPC.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/ValueStrategyPC.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/common/apps/ValueStrategyPC.java Fri Feb 15 01:19:55 2008 @@ -0,0 +1,132 @@ +/* + * 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.kernel.common.apps; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "valstratpc") +public class ValueStrategyPC { + + @Id + private int id; + + @Column(length = 35) + private String uuid; + @Column(length = 35) + private String uuidHex; + @Column(length = 35) + private String name; + @Column(name = "ignupdate") + private int ignoreUpdate; + @Column(name = "resupdate") + private int restrictUpdate; + private int version; + private int sequence; + + public ValueStrategyPC() { + } + + public ValueStrategyPC(int id) { + this.id = id; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public int getIgnoreUpdate() { + return this.ignoreUpdate; + } + + public void setIgnoreUpdate(int ignoreUpdate) { + this.ignoreUpdate = ignoreUpdate; + } + + public int getRestrictUpdate() { + return this.restrictUpdate; + } + + public void setRestrictUpdate(int restrictUpdate) { + this.restrictUpdate = restrictUpdate; + } + + public String getUUID() { + return this.uuid; + } + + public void setUUID(String uuid) { + this.uuid = uuid; + } + + public String getUUIDHex() { + return this.uuidHex; + } + + public void setUUIDHex(String uuidHex) { + this.uuidHex = uuidHex; + } + + public int getVersion() { + return this.version; + } + + public void setVersion(int version) { + this.version = version; + } + + public int getSequence() { + return this.sequence; + } + + public void setSequence(int sequence) { + this.sequence = sequence; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getUuidHex() { + return uuidHex; + } + + public void setUuidHex(String uuidHex) { + this.uuidHex = uuidHex; + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestClassMetaData.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestClassMetaData.java?rev=627979&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestClassMetaData.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestClassMetaData.java Fri Feb 15 01:19:55 2008 @@ -0,0 +1,309 @@ +/* + * 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.meta; + +import java.util.Map; +import javax.persistence.EntityManager; + + +import org.apache.openjpa.persistence.meta.common.apps.MetaTest1; +import org.apache.openjpa.persistence.meta.common.apps.MetaTest2; +import org.apache.openjpa.persistence.meta.common.apps.MetaTest3; +import org.apache.openjpa.persistence.meta.common.apps.MetaTest5; +import org.apache.openjpa.persistence.meta.common.apps.MetaTest6; +import org.apache.openjpa.persistence.common.utils.AbstractTestCase; +import org.apache.openjpa.enhance.PersistenceCapable; +import org.apache.openjpa.kernel.Broker; +import org.apache.openjpa.meta.ClassMetaData; +import org.apache.openjpa.meta.FieldMetaData; +import org.apache.openjpa.meta.JavaTypes; +import org.apache.openjpa.meta.MetaDataRepository; +import org.apache.openjpa.persistence.JPAFacadeHelper; + +/** + *

Tests the {@link ClassMetaData} type, and in so doing tests parts of + * the {@link MetaDataRepository} and {@link FieldMetaData} types.

+ * + * @author Abe White + */ +public class TestClassMetaData + extends AbstractTestCase { + + private MetaDataRepository _repos = null; + + private ClassMetaData _metaTest1 = null; + private ClassMetaData _metaTest2 = null; + private ClassMetaData _metaTest3 = null; + private ClassMetaData _metaTest5 = null; + private ClassMetaData _metaTest6 = null; + + public TestClassMetaData(String test) { + super(test, "metacactusapp"); + } + + public void setUp() + throws Exception { + _repos = getRepository(); + _metaTest5 = _repos.getMetaData(MetaTest5.class, null, true); + _metaTest3 = _repos.getMetaData(MetaTest3.class, null, true); + _metaTest2 = _repos.getMetaData(MetaTest2.class, null, true); + _metaTest1 = _repos.getMetaData(MetaTest1.class, null, true); + _metaTest6 = _repos.getMetaData(MetaTest6.class, null, true); + } + + protected MetaDataRepository getRepository() + throws Exception { + //return new OpenJPAConfigurationImpl().newMetaDataRepositoryInstance(); + //return getConfiguration().newMetaDataRepositoryInstance(); + EntityManager em = currentEntityManager(); + Broker broker = JPAFacadeHelper.toBroker(em); + return broker.getConfiguration().newMetaDataRepositoryInstance(); + } + + /** + * Test the class-level defaults. + */ + public void testClassDefaults() { + assertEquals(MetaTest1.class.getName(), + _metaTest1.getDescribedType().getName()); + assertNull(_metaTest1.getPCSuperclass()); + assertEquals(ClassMetaData.ID_DATASTORE, + _metaTest1.getIdentityType()); + assertTrue(_metaTest1.getRequiresExtent()); + } + + /** + * Test non-persistent fields. + */ + public void testDefaultNonPersistentFields() { + assertNull(_metaTest1.getField("staticField")); + assertNull(_metaTest1.getField("finalfield")); + assertNull(_metaTest1.getField("transientfield")); + assertNull(_metaTest1.getField("metaTest4Field")); + assertNull(_metaTest1.getField("metaTest4ArrayField")); + assertNull(_metaTest1.getField("objectField")); + assertNull(_metaTest1.getField("longWrapperField")); + + FieldMetaData fmd = _metaTest1.getField("doubleField"); + assertEquals(FieldMetaData.MANAGE_TRANSACTIONAL, fmd.getManagement()); + } + + /** + * Test basics on persistent fields. + */ + public void testBasicFields() { + FieldMetaData fmd; + fmd = _metaTest1.getField("stringField"); + assertEquals(JavaTypes.STRING, fmd.getTypeCode()); + assertEquals(JavaTypes.STRING, fmd.getDeclaredTypeCode()); + assertNull(fmd.getTypeMetaData()); + assertNull(fmd.getDeclaredTypeMetaData()); + fmd = _metaTest1.getField("intWrapperField"); + assertEquals(JavaTypes.INT_OBJ, fmd.getTypeCode()); + assertEquals(JavaTypes.INT_OBJ, fmd.getDeclaredTypeCode()); + fmd = _metaTest1.getField("intField"); + assertEquals(JavaTypes.INT, fmd.getTypeCode()); + assertEquals(JavaTypes.INT, fmd.getDeclaredTypeCode()); + fmd = _metaTest1.getField("metaTest2Field"); + assertEquals(JavaTypes.PC, fmd.getTypeCode()); + assertEquals(JavaTypes.PC, fmd.getDeclaredTypeCode()); + assertEquals(_metaTest2, fmd.getTypeMetaData()); + assertEquals(_metaTest2, fmd.getDeclaredTypeMetaData()); + fmd = _metaTest1.getField("metaTest2ArrayField"); + assertEquals(JavaTypes.ARRAY, fmd.getTypeCode()); + assertEquals(JavaTypes.PC, fmd.getElement().getTypeCode()); + assertEquals(JavaTypes.ARRAY, fmd.getDeclaredTypeCode()); + assertEquals(JavaTypes.PC, + fmd.getElement().getDeclaredTypeCode()); + fmd = _metaTest1.getField("intArrayField"); + assertEquals(JavaTypes.ARRAY, fmd.getTypeCode()); + assertEquals(JavaTypes.INT, fmd.getElement().getTypeCode()); + assertEquals(JavaTypes.ARRAY, fmd.getDeclaredTypeCode()); + assertEquals(JavaTypes.INT, + fmd.getElement().getDeclaredTypeCode()); + fmd = _metaTest1.getField("intField"); + assertEquals(FieldMetaData.NULL_EXCEPTION, fmd.getNullValue()); + assertTrue(!fmd.isInDefaultFetchGroup()); + assertTrue(!fmd.isEmbedded()); + fmd = _metaTest1.getField("stringField"); + assertEquals(FieldMetaData.NULL_UNSET, fmd.getNullValue()); + assertTrue(fmd.isInDefaultFetchGroup()); + assertTrue(fmd.isEmbedded()); + } + + /** + * Test collection and map fields. + */ + public void testCollectionFields() { + FieldMetaData fmd; + fmd = _metaTest2.getField("collectionField1"); + assertEquals(JavaTypes.COLLECTION, fmd.getTypeCode()); + assertEquals(JavaTypes.OBJECT, fmd.getElement().getTypeCode()); + assertEquals(Object.class, fmd.getElement().getType()); + assertNull(fmd.getElement().getTypeMetaData()); + assertEquals(JavaTypes.COLLECTION, + fmd.getDeclaredTypeCode()); + assertEquals(JavaTypes.OBJECT, + fmd.getElement().getDeclaredTypeCode()); + assertEquals(Object.class, fmd.getElement().getDeclaredType()); + assertNull(fmd.getElement().getTypeMetaData()); + assertTrue(fmd.getElement().isEmbedded()); + fmd = _metaTest2.getField("collectionField2"); + assertEquals(JavaTypes.COLLECTION, fmd.getTypeCode()); + assertEquals(JavaTypes.PC, fmd.getElement().getTypeCode()); + assertEquals(MetaTest3.class, fmd.getElement().getType()); + assertEquals(_metaTest3, fmd.getElement().getTypeMetaData()); + assertEquals(JavaTypes.COLLECTION, + fmd.getDeclaredTypeCode()); + assertEquals(JavaTypes.PC, + fmd.getElement().getDeclaredTypeCode()); + assertEquals(MetaTest3.class, fmd.getElement().getDeclaredType()); + assertEquals(_metaTest3, fmd.getElement().getDeclaredTypeMetaData()); + assertTrue(!fmd.getElement().isEmbedded()); + + fmd = _metaTest2.getField("mapField1"); + assertEquals(JavaTypes.MAP, fmd.getTypeCode()); + assertEquals(JavaTypes.OBJECT, fmd.getKey().getTypeCode()); + assertEquals(JavaTypes.OBJECT, fmd.getElement().getTypeCode()); + assertEquals(Object.class, fmd.getKey().getType()); + assertNull(fmd.getKey().getTypeMetaData()); + assertEquals(Object.class, fmd.getElement().getType()); + assertEquals(JavaTypes.MAP, fmd.getDeclaredTypeCode()); + assertEquals(JavaTypes.OBJECT, fmd.getKey().getDeclaredTypeCode()); + assertEquals(JavaTypes.OBJECT, + fmd.getElement().getDeclaredTypeCode()); + assertEquals(Object.class, fmd.getKey().getDeclaredType()); + assertNull(fmd.getKey().getDeclaredTypeMetaData()); + assertEquals(Object.class, fmd.getElement().getDeclaredType()); + assertTrue(fmd.getKey().isEmbedded()); + assertTrue(fmd.getElement().isEmbedded()); + fmd = _metaTest2.getField("mapField2"); + assertEquals(JavaTypes.MAP, fmd.getTypeCode()); + assertEquals(JavaTypes.STRING, fmd.getKey().getTypeCode()); + assertEquals(JavaTypes.INT_OBJ, fmd.getElement().getTypeCode()); + assertEquals(String.class, fmd.getKey().getType()); + assertEquals(Integer.class, fmd.getElement().getType()); + assertEquals(JavaTypes.MAP, fmd.getDeclaredTypeCode()); + assertEquals(JavaTypes.STRING, fmd.getKey().getDeclaredTypeCode()); + assertEquals(JavaTypes.INT_OBJ, + fmd.getElement().getDeclaredTypeCode()); + assertEquals(String.class, fmd.getKey().getDeclaredType()); + assertEquals(Integer.class, fmd.getElement().getDeclaredType()); + assertTrue(fmd.getKey().isEmbedded()); + assertTrue(!fmd.getElement().isEmbedded()); + } + + /** + * Test the basic class-level meta data. + */ + public void testBasicClass() { + assertEquals(_metaTest1, _metaTest2.getPCSuperclassMetaData()); + assertTrue(!_metaTest2.getRequiresExtent()); + } + + /** + * Test application identity. + */ + public void testApplicationIdentity() { + assertEquals(ClassMetaData.ID_APPLICATION, + _metaTest5.getIdentityType()); + assertEquals(MetaTest5.MetaTest5Id.class.getName(), + _metaTest5.getObjectIdType().getName()); + assertEquals(ClassMetaData.ID_APPLICATION, + _metaTest6.getIdentityType()); + assertEquals(MetaTest5.MetaTest5Id.class.getName(), + _metaTest6.getObjectIdType().getName()); + } + + /** + * Test absolute field numbering. + */ + public void testAbsoluteFieldNumbering() { + assertEquals(0, _metaTest1.getField("doubleField").getIndex()); + assertEquals(1, _metaTest1.getField("intArrayField").getIndex()); + assertEquals(2, _metaTest1.getField("intField").getIndex()); + assertEquals(3, _metaTest1.getField("intWrapperField").getIndex()); + assertEquals(4, _metaTest1.getField("metaTest2ArrayField"). + getIndex()); + assertEquals(5, _metaTest1.getField("metaTest2Field").getIndex()); + assertEquals(6, _metaTest1.getField("stringField").getIndex()); + assertEquals(7, _metaTest2.getField("collectionField1").getIndex()); + assertEquals(8, _metaTest2.getField("collectionField2").getIndex()); + assertEquals(9, _metaTest2.getField("mapField1").getIndex()); + assertEquals(10, _metaTest2.getField("mapField2").getIndex()); + } + + /** + * Test the methods to get fields. + */ + public void testGetFields() { + FieldMetaData[] fmds = _metaTest2.getFields(); + assertEquals("doubleField", fmds[0].getName()); + assertEquals("intField", fmds[2].getName()); + assertEquals("collectionField2", fmds[8].getName()); + } + + /** + * Test that metadata on inner classes is available. + */ + public void testStaticInnerClasses() { + assertNotNull(_repos.getMetaData(MetaTest1.Inner.class, null, true)); + } + + /** + * Test extensions for external values and declared vs external types. + */ + public void testExternalTypes() { + // note that below, declared type code is promoted + FieldMetaData fmd = _metaTest3.getField("pcField"); + assertEquals(JavaTypes.PC_UNTYPED, fmd.getTypeCode()); + assertEquals(JavaTypes.PC_UNTYPED, fmd.getDeclaredTypeCode()); + assertEquals(PersistenceCapable.class, fmd.getType()); + assertEquals(Object.class, fmd.getDeclaredType()); + assertNull(fmd.getDeclaredTypeMetaData()); + assertNull(fmd.getTypeMetaData()); + + // note that below, declared type code is promoted + fmd = _metaTest3.getField("metaField"); + assertEquals(JavaTypes.PC, fmd.getTypeCode()); + assertEquals(JavaTypes.PC, fmd.getDeclaredTypeCode()); + assertEquals(MetaTest2.class, fmd.getType()); + assertEquals(Object.class, fmd.getDeclaredType()); + assertEquals(_metaTest2, fmd.getDeclaredTypeMetaData()); + assertEquals(_metaTest2, fmd.getTypeMetaData()); + + fmd = _metaTest3.getField("externalField"); + assertTrue(fmd.isExternalized()); + assertEquals(JavaTypes.MAP, fmd.getTypeCode()); + assertEquals(JavaTypes.OBJECT, fmd.getDeclaredTypeCode()); + assertEquals(Map.class, fmd.getType()); + assertEquals(Object.class, fmd.getDeclaredType()); + assertEquals(JavaTypes.STRING, fmd.getKey().getTypeCode()); + assertEquals(JavaTypes.OBJECT, fmd.getKey().getDeclaredTypeCode()); + assertEquals(String.class, fmd.getKey().getType()); + assertEquals(Object.class, fmd.getKey().getDeclaredType()); + assertEquals(JavaTypes.PC, fmd.getElement().getTypeCode()); + assertEquals(JavaTypes.OBJECT, + fmd.getElement().getDeclaredTypeCode()); + assertEquals(MetaTest2.class, fmd.getElement().getType()); + assertEquals(Object.class, fmd.getElement().getDeclaredType()); + assertEquals(_metaTest2, fmd.getElement().getTypeMetaData()); + assertNull(fmd.getElement().getDeclaredTypeMetaData()); + } +}