From commits-return-2963-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Mon May 12 22:51:21 2008 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 15666 invoked from network); 12 May 2008 22:51:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 May 2008 22:51:21 -0000 Received: (qmail 55600 invoked by uid 500); 12 May 2008 22:51:23 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 55584 invoked by uid 500); 12 May 2008 22:51:23 -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 55573 invoked by uid 99); 12 May 2008 22:51:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 May 2008 15:51:23 -0700 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.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 May 2008 22:50:36 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 9463D2388999; Mon, 12 May 2008 15:50:57 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r655682 - in /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache: TestM2MInDataCache.java common/apps/M2MEntityE.java common/apps/M2MEntityF.java Date: Mon, 12 May 2008 22:50:57 -0000 To: commits@openjpa.apache.org From: pcl@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080512225057.9463D2388999@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pcl Date: Mon May 12 15:50:57 2008 New Revision: 655682 URL: http://svn.apache.org/viewvc?rev=655682&view=rev Log: OPENJPA-589. Committing test cases on behalf of Fay Wang. Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestM2MInDataCache.java openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/common/apps/M2MEntityE.java openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/common/apps/M2MEntityF.java Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestM2MInDataCache.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestM2MInDataCache.java?rev=655682&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestM2MInDataCache.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestM2MInDataCache.java Mon May 12 15:50:57 2008 @@ -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.datacache; + +import javax.persistence.EntityManager; +import org.apache.openjpa.persistence.datacache.common.apps.M2MEntityE; +import org.apache.openjpa.persistence.datacache.common.apps.M2MEntityF; +import org.apache.openjpa.persistence.test.SingleEMFTestCase; + +public class TestM2MInDataCache extends SingleEMFTestCase { + public void setUp() { + setUp("openjpa.DataCache", "true", + "openjpa.RemoteCommitProvider", "sjvm", + M2MEntityE.class, + M2MEntityF.class, CLEAR_TABLES); + } + + /** + * Test if child list is in order after new child list is added in setup(). + * + */ + public void testM2MDataCache(){ + EntityManager em = emf.createEntityManager(); + em.getTransaction().begin(); + + M2MEntityE e1 = new M2MEntityE(); + e1.setId(1); + e1.setName("ABC"); + em.persist(e1); + M2MEntityE e2 = new M2MEntityE(); + e2.setId(2); + e2.setName("DEF"); + em.persist(e2); + + M2MEntityF f1 = new M2MEntityF(); + f1.setId(10); + em.persist(f1); + M2MEntityF f2 = new M2MEntityF(); + f2.setId(20); + em.persist(f2); + + e1.getEntityF().put(f1.getId(), f1); + e1.getEntityF().put(f2.getId(), f2); + e2.getEntityF().put(f1.getId(), f1); + e2.getEntityF().put(f2.getId(), f2); + + f1.getEntityE().put(e1.getName(), e1); + f1.getEntityE().put(e2.getName(), e2); + f2.getEntityE().put(e1.getName(), e1); + f2.getEntityE().put(e2.getName(), e2); + e1.print(); + e2.print(); + f1.print(); + f2.print(); + em.getTransaction().commit(); + em.close(); + + em = emf.createEntityManager(); + M2MEntityE e1a = em.find(M2MEntityE.class, 1); + M2MEntityE e2a = em.find(M2MEntityE.class, 2); + M2MEntityF f1a = em.find(M2MEntityF.class, 10); + M2MEntityF f2a = em.find(M2MEntityF.class, 20); + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/common/apps/M2MEntityE.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/common/apps/M2MEntityE.java?rev=655682&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/common/apps/M2MEntityE.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/common/apps/M2MEntityE.java Mon May 12 15:50:57 2008 @@ -0,0 +1,61 @@ +/* + * 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.datacache.common.apps; +import javax.persistence.*; +import java.util.*; + +@Entity +public class M2MEntityE { + @Id private int id; + private String name; + + @ManyToMany + @MapKey(name="id") + private Map entityf; + + public M2MEntityE() { + entityf = new HashMap(); + name="entitye"; + } + + public Map getEntityF() { + return entityf; + } + public int getId() { + return id; + } + public void setId(int id) { + this.id = id; + } + public String toString(){ + return "EntityE:"+id; + } + public void print(){ + System.out.println("EntityD id="+id+" entityc="+ entityf); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/common/apps/M2MEntityF.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/common/apps/M2MEntityF.java?rev=655682&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/common/apps/M2MEntityF.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/common/apps/M2MEntityF.java Mon May 12 15:50:57 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.datacache.common.apps; + +import javax.persistence.*; +import java.util.*; + +@Entity +public class M2MEntityF { + @Id private int id; + + @ManyToMany(mappedBy="entityf") + @MapKey(name="name") + private Map entitye; + + public M2MEntityF() { + entitye = new HashMap(); + } + public Map getEntityE() { + return entitye; + } + public int getId() { + return id; + } + public void setId(int id) { + this.id = id; + } + public String toString(){ + return "EntityF:"+id; + } + public void print(){ + System.out.println("EntityF id="+id+" entitye="+ entitye); + } + +}