Index: openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/UnenhancedCompoundPKFieldAccessSuperclass.java =================================================================== --- openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/UnenhancedCompoundPKFieldAccessSuperclass.java (revision 0) +++ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/UnenhancedCompoundPKFieldAccessSuperclass.java (revision 0) @@ -0,0 +1,85 @@ +/** + * + * 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.enhance; + +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.MappedSuperclass; + +@MappedSuperclass +@IdClass(UnenhancedCompoundPKFieldAccessSuperclass.PK.class) +public class UnenhancedCompoundPKFieldAccessSuperclass { + + @Id + private int id0; + @Id private int id1; + + protected UnenhancedCompoundPKFieldAccessSuperclass() { + } + + public UnenhancedCompoundPKFieldAccessSuperclass( + int i0, int i1) { + id0 = i0; + id1 = i1; + } + + public static class PK { + static { + // register persistent class in JVM + try { + Class.forName(UnenhancedCompoundPKFieldAccessSuperclass.class.getName()); + } catch (Exception e) { + // ignore + } + } + + public int id0; + public int id1; + + public PK() { + } + + public PK(int i0, int i1) { + id0 = i0; + id1 = i1; + } + + public String toString() { + return String.valueOf(id0) + + "::" + String.valueOf(id1); + } + + public int hashCode() { + int rs = 17; + rs = rs * 37 + (int) (id0 ^ (id1 >>> 32)); + rs = rs * 37 + (int) (id0 ^ (id1 >>> 32)); + return rs; + } + + public boolean equals(Object obj) { + if(this == obj) + return true; + if(obj == null || obj.getClass() != getClass()) + return false; + + UnenhancedCompoundPKFieldAccessSuperclass.PK other = (UnenhancedCompoundPKFieldAccessSuperclass.PK) obj; + return (id0 == other.id0) + && (id1 == other.id1); + } + } +} Index: openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestUnenhancedCompoundPKSubclass.java =================================================================== --- openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestUnenhancedCompoundPKSubclass.java (revision 0) +++ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestUnenhancedCompoundPKSubclass.java (revision 0) @@ -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.enhance; + +import org.apache.openjpa.persistence.test.SingleEMTestCase; + +public class TestUnenhancedCompoundPKSubclass extends SingleEMTestCase { + + public void setUp() { + setUp(UnenhancedCompoundPKFieldAccessSuperclass.class, UnenhancedCompoundPKFieldAccessSubclass.class, CLEAR_TABLES); + } + + public void testNothing() { + // maven requires that there be atleast one test method + } + + public void XtestCompoundPKFieldAccessUserDefined() { + UnenhancedCompoundPKFieldAccessSuperclass un = new UnenhancedCompoundPKFieldAccessSubclass(17, 31); + UnenhancedCompoundPKFieldAccessSuperclass.PK oid = new UnenhancedCompoundPKFieldAccessSuperclass.PK(17, 31); + compoundPKHelper(un, oid, true); + } + + public void XtestCompoundPKFieldAccessOpenJPADefined() { + UnenhancedCompoundPKFieldAccessSuperclass un = new UnenhancedCompoundPKFieldAccessSubclass(17, 31); + UnenhancedCompoundPKFieldAccessSuperclass.PK oid = new UnenhancedCompoundPKFieldAccessSuperclass.PK(17, 31); + compoundPKHelper(un, oid, false); + } + + private void compoundPKHelper(Object o, Object oid, boolean userDefined) { + em.getTransaction().begin(); + em.persist(o); + em.getTransaction().commit(); + + if (!userDefined) { + em.close(); + em = emf.createEntityManager(); + } + + em.find(o.getClass(), oid); + } +} Index: openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/UnenhancedCompoundPKFieldAccessSubclass.java =================================================================== --- openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/UnenhancedCompoundPKFieldAccessSubclass.java (revision 0) +++ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/UnenhancedCompoundPKFieldAccessSubclass.java (revision 0) @@ -0,0 +1,34 @@ +/** + * + * 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.enhance; + +import javax.persistence.MappedSuperclass; +import javax.persistence.IdClass; +import javax.persistence.Id; +import javax.persistence.Entity; + +@Entity +@IdClass(UnenhancedCompoundPKFieldAccessSubclass.PK.class) +public class UnenhancedCompoundPKFieldAccessSubclass extends UnenhancedCompoundPKFieldAccessSuperclass { + public UnenhancedCompoundPKFieldAccessSubclass() { + } + + public UnenhancedCompoundPKFieldAccessSubclass(int i0, int i1) { + super(i0, i1); + } +}