openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jrba...@apache.org
Subject svn commit: r1087054 - in /openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/m...
Date Wed, 30 Mar 2011 19:32:42 GMT
Author: jrbauer
Date: Wed Mar 30 19:32:41 2011
New Revision: 1087054

URL: http://svn.apache.org/viewvc?rev=1087054&view=rev
Log:
OPENJPA-1966 Updated attach strategies to query attach cache before going to the broker for
entity references.  Prevents merging in a detached entity that is being used for field attachment.

Added:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/TestMergeDetachStateField.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Car.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Label.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Label2.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Make.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Model.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/ShipPackage.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/ShipPackage2.java
  (with props)
Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AttachStrategy.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedStateManager.java

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AttachStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AttachStrategy.java?rev=1087054&r1=1087053&r2=1087054&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AttachStrategy.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AttachStrategy.java
Wed Mar 30 19:32:41 2011
@@ -186,13 +186,21 @@ abstract class AttachStrategy
                 Object frmpc = fetchObjectField(i);
                 if (frmpc == null && !nullLoaded)
                     return false;
+
                 OpenJPAStateManager tosm = manager.getBroker().getStateManager
                     (sm.fetchObjectField(i));
                 PersistenceCapable topc = (tosm == null) ? null
                     : tosm.getPersistenceCapable();
                 if (frmpc != null || topc != null) {
-                    if (fmd.getCascadeAttach() == ValueMetaData.CASCADE_NONE)
-                        frmpc = getReference(manager, frmpc, sm, fmd);
+                    if (fmd.getCascadeAttach() == ValueMetaData.CASCADE_NONE) {
+                        // Use the attached copy of the object, if available
+                        PersistenceCapable cpy = manager.getAttachedCopy(frmpc);
+                        if (cpy != null) {
+                            frmpc = cpy;
+                        } else {
+                        	frmpc = getReference(manager, frmpc, sm, fmd);
+                        }
+                    }
                     else {
                         PersistenceCapable intopc = topc;
                         if (!fmd.isEmbeddedPC() && frmpc != null && topc
!= null

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedStateManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedStateManager.java?rev=1087054&r1=1087053&r2=1087054&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedStateManager.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedStateManager.java
Wed Mar 30 19:32:41 2011
@@ -244,8 +244,15 @@ public class DetachedStateManager
                 case JavaTypes.PC:
                 case JavaTypes.PC_UNTYPED:
                     if (fields[i].getCascadeAttach() == ValueMetaData
-                        .CASCADE_NONE)
-                        objval = getReference(manager, objval, sm, fields[i]);
+                        .CASCADE_NONE) {
+                        // Use the attached copy of the object, if available
+                        PersistenceCapable cpy = manager.getAttachedCopy(objval);
+                        if (cpy != null) {
+                            objval = cpy;
+                        } else {
+                        	objval = getReference(manager, objval, sm, fields[i]);
+                        }
+                    } 
                     else {
                         PersistenceCapable toPC = null;
                         if (objval != null && fields[i].isEmbeddedPC())

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/TestMergeDetachStateField.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/TestMergeDetachStateField.java?rev=1087054&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/TestMergeDetachStateField.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/TestMergeDetachStateField.java
Wed Mar 30 19:32:41 2011
@@ -0,0 +1,230 @@
+/*
+ * 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.merge;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+
+import org.apache.openjpa.persistence.merge.model.Car;
+import org.apache.openjpa.persistence.merge.model.Label;
+import org.apache.openjpa.persistence.merge.model.Label2;
+import org.apache.openjpa.persistence.merge.model.Make;
+import org.apache.openjpa.persistence.merge.model.Model;
+import org.apache.openjpa.persistence.merge.model.ShipPackage;
+import org.apache.openjpa.persistence.merge.model.ShipPackage2;
+import org.apache.openjpa.persistence.test.SingleEMFTestCase;
+
+public class TestMergeDetachStateField extends SingleEMFTestCase {
+    public void setUp() {
+        setUp(Label.class, ShipPackage.class, 
+        	  Label2.class, ShipPackage2.class,
+        	  Car.class, Model.class, Make.class,
+        	  CLEAR_TABLES);
+    }
+
+    /** 
+     * Verify a merge graph is correct when an entity uses a detached state field.  When
+     * a detached state field is used, the entity does not get populated with a DetachedStateManager
+     * upon detachment.
+     *  
+     * ShipPackage: Has DetachedStateManager after detach.
+     * Label: Detached state field - no DSM after detach.
+     * Initial graph:  Label <--> ShipPackage
+     * Merge: Label
+     * Verify after merge:  Label' <--> ShipPackage'
+     */
+    public void testCascadeMergeDetachState() {
+        EntityManager em = emf.createEntityManager();
+
+        try {
+            // Create simple bi-di graph
+        	ShipPackage p = new ShipPackage();
+            Label l = new Label(p);
+            p.setLabel(l);
+            
+            // Persist
+            em.getTransaction().begin();
+            em.persist(l);
+            em.getTransaction().commit();
+
+            // Detach
+            em.clear();
+            assertFalse(em.contains(l));
+            assertFalse(em.contains(p));
+            assertFalse(em.contains(l.getPackage()));
+            assertFalse(em.contains(p.getLabel()));
+            
+            em.getTransaction().begin();
+            Label mergedLabel = em.merge(l);
+
+            assertFalse(mergedLabel == l);
+            assertFalse(p == mergedLabel.getPackage());
+            // Assert that the bi-directional relationship points to the
+            // newly merged entity
+            assertTrue(mergedLabel == mergedLabel.getPackage().getLabel());
+            assertFalse(l == mergedLabel.getPackage().getLabel());
+            em.remove(mergedLabel);
+            em.getTransaction().commit();
+        } finally {
+            if (em != null) {
+                if (em.getTransaction().isActive())
+                    em.getTransaction().rollback();
+                em.close();
+            }
+        }
+    }
+
+    /** 
+     * Verify a merge graph is correct when an entity uses a detached state field.  When
+     * a detached state field is used, the entity does not get populated with a DetachedStateManager
+     * upon detachment.  Same as testCascadeMergeDetachState, except merge is on ShipPackage2,
+     * which contains the cascade instead of Label2.
+     *  
+     * ShipPackage: Has DetachedStateManager after detach.
+     * Label: Detached state field - no DSM after detach.
+     * Initial graph:  ShipPackage2 <--> Label2
+     * Merge: ShipPackage2
+     * Verify after merge: ShipPackage2' <-->  Label2' 
+     */
+    public void testCascadeMergeDetachState2() {
+        EntityManager em = emf.createEntityManager();
+
+        try {
+            // Create simple bi-di graph
+        	ShipPackage2 p = new ShipPackage2();
+            Label2 l = new Label2(p);
+            p.setLabel2(l);
+            
+            // Persist
+            em.getTransaction().begin();
+            em.persist(p);
+            em.getTransaction().commit();
+
+            // Detach
+            em.clear();
+            assertFalse(em.contains(l));
+            assertFalse(em.contains(p));
+            assertFalse(em.contains(l.getPackage2()));
+            assertFalse(em.contains(p.getLabel2()));
+            
+            em.getTransaction().begin();
+            ShipPackage2 mergedPackage = em.merge(p);
+
+            assertFalse(mergedPackage == p);
+            assertFalse(l == mergedPackage.getLabel2());
+            // Assert that the bi-directional relationship points to the
+            // newly merged entity
+            assertTrue(mergedPackage == mergedPackage.getLabel2().getPackage2());
+            assertFalse(p == mergedPackage.getLabel2().getPackage2());
+            em.remove(mergedPackage);
+            em.getTransaction().commit();
+        } finally {
+            if (em != null) {
+                if (em.getTransaction().isActive())
+                    em.getTransaction().rollback();
+                em.close();
+            }
+        }
+    }
+
+    /** 
+     * Verify a merge graph is correct when multiple entities of a complex
+     * graph use a detached state field.  When a detached state field is used, 
+     * the entity does not get populated with a DetachedStateManager upon 
+     * detachment, but merge should still succeed.
+     */
+    public void testCascadeMergeDetachStateComplex() {
+        EntityManager em = emf.createEntityManager();
+
+        try {
+        	Car c1 = new Car();
+        	Car c2 = new Car();
+        	Make mk1 = new Make();
+        	ArrayList<Model> models = new ArrayList<Model>();
+        	Model md1 = new Model();
+        	models.add(md1);
+        	Model md2 = new Model();
+        	models.add(md2);
+
+        	//populate bidirectional relationships
+        	c1.setModel(md1);
+        	c2.setModel(md2);        	
+        	md1.setCar(c1);
+        	md1.setMake(mk1);
+        	md2.setCar(c2);
+        	md1.setMake(mk1);
+        	mk1.setModels(models);
+        	            
+            // Persist car1 - will cascade
+            em.getTransaction().begin();
+            em.persist(c1);
+            em.getTransaction().commit();
+
+            Object[] entities = new Object[] { c1, c2, mk1, md1, md2 };
+            // detach all
+            em.clear();
+            // verify all entities are detached and references to them
+            // are also detached.
+            verifyDetached(em, entities);
+            
+            em.getTransaction().begin();
+            // Merge model back in and verify all entities are newly merged entities
+            Model mergedModel = em.merge(md1);
+            assertFalse(mergedModel == md1);
+            assertFalse(mergedModel.getMake() == mk1);
+            List<Model> mds = mergedModel.getMake().getModels();
+            assertTrue(mds.contains(mergedModel));
+            assertFalse(c1 == mergedModel.getCar());
+            assertTrue(mergedModel.getCar().getModel() == mergedModel);            
+            em.remove(mergedModel);
+            em.getTransaction().commit();
+        } finally {
+            if (em != null) {
+                if (em.getTransaction().isActive())
+                    em.getTransaction().rollback();
+                em.close();
+            }
+        }
+    }
+
+	private void verifyDetached(EntityManager em, Object[] entities) {
+        for (Object entity : entities) {
+        	assertFalse(em.contains(entity));
+        	if (entity instanceof Car) {
+        		Car c = (Car)entity;
+        		assertFalse(em.contains(c.getModel()));
+        	}
+        	else if (entity instanceof Make) {
+        		Make m = (Make)entity;
+        		List<Model> mds = m.getModels();
+        		for (Model md : mds) {
+        			assertFalse(em.contains(md));
+        		}
+        	}
+        	else if (entity instanceof Model) {
+        		Model m = (Model)entity;
+        		assertFalse(em.contains(m.getCar()));
+        		assertFalse(em.contains(m.getMake()));
+        	}
+        }
+	}
+
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/TestMergeDetachStateField.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Car.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Car.java?rev=1087054&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Car.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Car.java
Wed Mar 30 19:32:41 2011
@@ -0,0 +1,62 @@
+/*
+ * 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.merge.model;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.Version;
+
+@Entity
+@Table(name="MRG_CAR")
+public class Car {
+
+	@Id
+	@GeneratedValue
+	@Column(name="CAR_ID")
+	private long id;
+	
+	@OneToOne(cascade=CascadeType.ALL, mappedBy="car")
+	private Model model;
+	
+    @SuppressWarnings("unused")
+    @Version
+    private int version;
+
+		
+	public void setId(long id) {
+		this.id = id;
+	}
+
+	public long getId() {
+		return id;
+	}
+
+	public void setModel(Model model) {
+		this.model = model;
+	}
+
+	public Model getModel() {
+		return model;
+	}
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Car.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Label.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Label.java?rev=1087054&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Label.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Label.java
Wed Mar 30 19:32:41 2011
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.merge.model;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+import javax.persistence.Version;
+
+import org.apache.openjpa.persistence.DetachedState;
+import org.apache.openjpa.persistence.jdbc.ForeignKey;
+
+@Entity
+@Table(name = "MRG_LABEL")
+@TableGenerator(name = "LabelGen", allocationSize = 10, pkColumnValue = "MRG_LABEL")
+public class Label {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.TABLE, generator = "LabelGen")
+    @Column(name = "LABEL_ID")
+    private long id;
+
+    @OneToOne(cascade = CascadeType.ALL)
+    @ForeignKey()
+    @JoinColumn(name = "PKG_ID")
+    private ShipPackage pkg;
+
+    @SuppressWarnings("unused")
+    @Version
+    private int version;
+
+    @SuppressWarnings("unused")
+    @DetachedState
+    private Object state;
+
+    public Label(ShipPackage p) {
+        setPackage(p);
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public void setPackage(ShipPackage p) {
+        pkg = p;
+    }
+
+    public ShipPackage getPackage() {
+        return pkg;
+    }
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Label.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Label2.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Label2.java?rev=1087054&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Label2.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Label2.java
Wed Mar 30 19:32:41 2011
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.merge.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+import javax.persistence.Version;
+
+import org.apache.openjpa.persistence.DetachedState;
+import org.apache.openjpa.persistence.jdbc.ForeignKey;
+
+@Entity
+@Table(name = "MRG_LABEL2")
+@TableGenerator(name = "Label2Gen", allocationSize = 10, pkColumnValue = "MRG_LABEL2")
+public class Label2 {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.TABLE, generator = "Label2Gen")
+    @Column(name = "LABEL_ID")
+    private long id;
+
+    @OneToOne
+    @ForeignKey
+    @JoinColumn(name = "PKG_ID")
+    private ShipPackage2 pkg;
+
+    @SuppressWarnings("unused")
+    @Version
+    private int version;
+
+    @SuppressWarnings("unused")
+    @DetachedState
+    private Object state;
+
+    public Label2(ShipPackage2 p) {
+        setPackage2(p);
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public void setPackage2(ShipPackage2 p) {
+        pkg = p;
+    }
+
+    public ShipPackage2 getPackage2() {
+        return pkg;
+    }
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Label2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Make.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Make.java?rev=1087054&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Make.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Make.java
Wed Mar 30 19:32:41 2011
@@ -0,0 +1,69 @@
+/*
+ * 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.merge.model;
+
+import java.util.List;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.Version;
+
+import org.apache.openjpa.persistence.DetachedState;
+
+@Entity
+@Table(name="MRG_MAKE")
+public class Make {
+
+	@Id
+	@GeneratedValue
+	@Column(name="MAKE_ID")
+	private long id;
+
+	@OneToMany(cascade=CascadeType.ALL)
+	private List<Model> models;
+		
+    @SuppressWarnings("unused")
+    @Version
+    private int version;
+    
+	@SuppressWarnings("unused")
+	@DetachedState
+	private Object state;
+
+	public void setId(long id) {
+		this.id = id;
+	}
+
+	public long getId() {
+		return id;
+	}
+
+	public void setModels(List<Model> models) {
+		this.models = models;
+	}
+
+	public List<Model> getModels() {
+		return models;
+	}
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Make.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Model.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Model.java?rev=1087054&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Model.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Model.java
Wed Mar 30 19:32:41 2011
@@ -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.merge.model;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.Version;
+
+import org.apache.openjpa.persistence.jdbc.ForeignKey;
+
+@Entity
+@Table(name="MRG_MODEL")
+public class Model {
+
+	@Id
+	@GeneratedValue
+	@Column(name="MODEL_ID")
+	private long id;
+
+	@ManyToOne(cascade=CascadeType.ALL)
+	@ForeignKey
+	@JoinColumn(name="MAKE_ID")
+	private Make make;
+	
+	@OneToOne(cascade=CascadeType.ALL)
+	@ForeignKey
+	@JoinColumn(name="CAR_ID")
+	private Car car;
+
+    @SuppressWarnings("unused")
+    @Version
+    private int version;
+
+	public void setId(long id) {
+		this.id = id;
+	}
+
+	public long getId() {
+		return id;
+	}
+
+	public void setMake(Make make) {
+		this.make = make;
+	}
+
+	public Make getMake() {
+		return make;
+	}
+
+	public void setCar(Car car) {
+		this.car = car;
+	}
+
+	public Car getCar() {
+		return car;
+	}
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/Model.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/ShipPackage.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/ShipPackage.java?rev=1087054&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/ShipPackage.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/ShipPackage.java
Wed Mar 30 19:32:41 2011
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.merge.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+import javax.persistence.Version;
+
+@Entity
+@Table(name = "MRG_PACKAGE")
+@TableGenerator(name = "PkgGen", allocationSize = 10, pkColumnValue = "MRG_PACKAGE")
+public class ShipPackage {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.TABLE, generator = "PkgGen")
+    @Column(name = "PKG_ID")
+    private long id;
+
+    @OneToOne(mappedBy = "pkg", fetch = FetchType.EAGER)
+    private Label label;
+
+    @SuppressWarnings("unused")
+    @Version
+    private int version;
+
+    public void setId(long pid) {
+        id = pid;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public void setLabel(Label l) {
+        label = l;
+    }
+
+    public Label getLabel() {
+        return label;
+    }    
+
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/ShipPackage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/ShipPackage2.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/ShipPackage2.java?rev=1087054&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/ShipPackage2.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/ShipPackage2.java
Wed Mar 30 19:32:41 2011
@@ -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.merge.model;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+import javax.persistence.Version;
+
+@Entity
+@Table(name = "MRG_PACKAGE2")
+@TableGenerator(name = "Pkg2Gen", allocationSize = 10, pkColumnValue = "MRG_PACKAGE2")
+public class ShipPackage2 {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.TABLE, generator = "Pkg2Gen")
+    @Column(name = "PKG_ID")
+    private long id;
+
+    @OneToOne(mappedBy = "pkg", fetch = FetchType.EAGER, cascade=CascadeType.ALL)
+    private Label2 label;
+
+    @SuppressWarnings("unused")
+    @Version
+    private int version;
+
+    public void setId(long pid) {
+        id = pid;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public void setLabel2(Label2 l) {
+        label = l;
+    }
+
+    public Label2 getLabel2() {
+        return label;
+    }    
+
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/model/ShipPackage2.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message