openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgras...@apache.org
Subject svn commit: r1636422 - in /openjpa/branches/2.2.1.x: openjpa-kernel/src/main/java/org/apache/openjpa/meta/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/ openjpa-persistence-jdbc/src/test/resources/org/apache/o...
Date Mon, 03 Nov 2014 19:23:31 GMT
Author: jgrassel
Date: Mon Nov  3 19:23:30 2014
New Revision: 1636422

URL: http://svn.apache.org/r1636422
Log:
OPENJPA-1988: openjpa does not process persistence unit default <cascade-persist>

Added:
    openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/
    openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/AnEmbeddable.java   (with props)
    openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/EmbeddableWithRelationships.java   (with props)
    openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityA01.java   (with props)
    openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityA02.java   (with props)
    openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityAE01.java   (with props)
    openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityB.java   (with props)
    openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/TestNoPUDefaultCascadePersist.java   (with props)
    openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/TestPUDefaultCascadePersist.java   (with props)
    openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/cascade/
    openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/cascade/pudefault/
    openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/cascade/pudefault/META-INF/
    openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/cascade/pudefault/META-INF/cascadepersistorm.xml   (with props)
    openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/cascade/pudefault/META-INF/persistence.xml   (with props)
Modified:
    openjpa/branches/2.2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ValueMetaDataImpl.java

Modified: openjpa/branches/2.2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ValueMetaDataImpl.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ValueMetaDataImpl.java?rev=1636422&r1=1636421&r2=1636422&view=diff
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ValueMetaDataImpl.java (original)
+++ openjpa/branches/2.2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ValueMetaDataImpl.java Mon Nov  3 19:23:30 2014
@@ -234,23 +234,48 @@ public class ValueMetaDataImpl
         _delete = delete;
     }
 
-    public int getCascadePersist() {
-        if (_checkPUDefaultCascadePersist) {
-            Boolean dcpe = getRepository().getMetaDataFactory().getDefaults().isDefaultCascadePersistEnabled();
-            if (dcpe != null && dcpe.equals(Boolean.TRUE)) {
-                _persist = CASCADE_IMMEDIATE;
-            }
-            _checkPUDefaultCascadePersist = false;
-        }
-        
+    public int getCascadePersist() {    
         if (_owner.getManagement() != FieldMetaData.MANAGE_PERSISTENT)
             return CASCADE_NONE;
-        if (isDeclaredTypePC())
-            return _persist;
+        if (isDeclaredTypePC()) {
+            return checkPUDefaultCascadePersist();
+        }
         if (!isTypePC())
             return CASCADE_NONE;
         // if only externalized type is pc, can't cascade immediate
-        return (_persist == CASCADE_IMMEDIATE) ? CASCADE_AUTO : _persist;
+        return (_persist == CASCADE_IMMEDIATE) ? CASCADE_AUTO : checkPUDefaultCascadePersist();
+    }
+    
+    /**
+     * Check if the persistence unit default <cascade-persist> has been enabled.  If so, then change
+     * CASCADE_NONE to CASCADE_IMMEDIATE.
+     * @return
+     */
+    private int checkPUDefaultCascadePersist() {
+        if (_checkPUDefaultCascadePersist) {
+            // Apply default <cascade-persist> only to entity relationships
+            boolean applyDefaultCascadePersist = false;
+            
+            switch (_owner.getAssociationType()) {
+            case FieldMetaData.ONE_TO_ONE:
+            case FieldMetaData.ONE_TO_MANY:
+            case FieldMetaData.MANY_TO_MANY:
+            case FieldMetaData.MANY_TO_ONE:
+                applyDefaultCascadePersist = true;
+            default:
+            }
+            
+            if (applyDefaultCascadePersist) {
+                Boolean dcpe = getRepository().getMetaDataFactory().getDefaults().isDefaultCascadePersistEnabled();
+                if (dcpe != null && dcpe.equals(Boolean.TRUE) && _persist == CASCADE_NONE) {
+                    _persist = CASCADE_IMMEDIATE;
+                }
+            }        
+            
+            _checkPUDefaultCascadePersist = false;
+        }
+        
+        return _persist;
     }
 
     public void setCascadePersist(int persist) {

Added: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/AnEmbeddable.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/AnEmbeddable.java?rev=1636422&view=auto
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/AnEmbeddable.java (added)
+++ openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/AnEmbeddable.java Mon Nov  3 19:23:30 2014
@@ -0,0 +1,47 @@
+/*
+ * 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.cascade.pudefault;
+
+import javax.persistence.Basic;
+import javax.persistence.Embeddable;
+
+@Embeddable
+public class AnEmbeddable {
+    @Basic
+    private String eStrData;
+    
+    public AnEmbeddable() {
+        
+    }
+
+    public String geteStrData() {
+        return eStrData;
+    }
+
+    public void seteStrData(String eStrData) {
+        this.eStrData = eStrData;
+    }
+
+    @Override
+    public String toString() {
+        return "AnEmbeddable [eStrData=" + eStrData + "]";
+    }
+    
+    
+}

Propchange: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/AnEmbeddable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/EmbeddableWithRelationships.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/EmbeddableWithRelationships.java?rev=1636422&view=auto
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/EmbeddableWithRelationships.java (added)
+++ openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/EmbeddableWithRelationships.java Mon Nov  3 19:23:30 2014
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.cascade.pudefault;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.persistence.Embeddable;
+import javax.persistence.ManyToMany;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+
+@Embeddable
+public class EmbeddableWithRelationships {
+    @ManyToMany
+    private Collection<PUDEntityB> colM2M;
+    
+    @OneToMany
+    private Collection<PUDEntityB> colO2M;
+    
+    @ManyToOne
+    private PUDEntityB m2o;
+    
+    @OneToOne
+    private PUDEntityB o2o;
+    
+    public EmbeddableWithRelationships() {
+        colM2M = new ArrayList<PUDEntityB>();
+        colO2M = new ArrayList<PUDEntityB>();
+    }
+    
+    public Collection<PUDEntityB> getColM2M() {
+        return colM2M;
+    }
+
+    public void setColM2M(Collection<PUDEntityB> colM2M) {
+        this.colM2M = colM2M;
+    }
+
+    public Collection<PUDEntityB> getColO2M() {
+        return colO2M;
+    }
+
+    public void setColO2M(Collection<PUDEntityB> colO2M) {
+        this.colO2M = colO2M;
+    }
+
+    public PUDEntityB getM2o() {
+        return m2o;
+    }
+
+    public void setM2o(PUDEntityB m2o) {
+        this.m2o = m2o;
+    }
+
+    public PUDEntityB getO2o() {
+        return o2o;
+    }
+
+    public void setO2o(PUDEntityB o2o) {
+        this.o2o = o2o;
+    }
+
+    @Override
+    public String toString() {
+        return "EmbeddableWithRelationships [colM2M=" + colM2M + ", colO2M="
+            + colO2M + ", m2o=" + m2o + ", o2o=" + o2o + "]";
+    }
+    
+    
+}

Propchange: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/EmbeddableWithRelationships.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityA01.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityA01.java?rev=1636422&view=auto
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityA01.java (added)
+++ openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityA01.java Mon Nov  3 19:23:30 2014
@@ -0,0 +1,116 @@
+/*
+ * 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.cascade.pudefault;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.persistence.Basic;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+
+@Entity
+public class PUDEntityA01 {
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    private int id;
+    
+    @Basic
+    private String strData;
+    
+    @ManyToMany
+    private Collection<PUDEntityB> colM2M;
+    
+    @OneToMany
+    private Collection<PUDEntityB> colO2M;
+    
+    @ManyToOne
+    private PUDEntityB m2o;
+    
+    @OneToOne
+    private PUDEntityB o2o;
+    
+    public PUDEntityA01() {
+        colM2M = new ArrayList<PUDEntityB>();
+        colO2M = new ArrayList<PUDEntityB>();
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getStrData() {
+        return strData;
+    }
+
+    public void setStrData(String strData) {
+        this.strData = strData;
+    }
+
+    public Collection<PUDEntityB> getColM2M() {
+        return colM2M;
+    }
+
+    public void setColM2M(Collection<PUDEntityB> colM2M) {
+        this.colM2M = colM2M;
+    }
+
+    public Collection<PUDEntityB> getColO2M() {
+        return colO2M;
+    }
+
+    public void setColO2M(Collection<PUDEntityB> colO2M) {
+        this.colO2M = colO2M;
+    }
+
+    public PUDEntityB getM2o() {
+        return m2o;
+    }
+
+    public void setM2o(PUDEntityB m2o) {
+        this.m2o = m2o;
+    }
+
+    public PUDEntityB getO2o() {
+        return o2o;
+    }
+
+    public void setO2o(PUDEntityB o2o) {
+        this.o2o = o2o;
+    }
+
+    @Override
+    public String toString() {
+        return "PUDEntityA01 [id=" + id + ", strData=" + strData + ", colM2M="
+            + colM2M + ", colO2M=" + colO2M + ", m2o=" + m2o + ", o2o=" + o2o
+            + "]";
+    }
+    
+    
+}

Propchange: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityA01.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityA02.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityA02.java?rev=1636422&view=auto
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityA02.java (added)
+++ openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityA02.java Mon Nov  3 19:23:30 2014
@@ -0,0 +1,75 @@
+/*
+ * 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.cascade.pudefault;
+
+import javax.persistence.Basic;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity
+public class PUDEntityA02 {
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    private int id;
+    
+    @Basic
+    private String strData;
+    
+    @Embedded
+    private EmbeddableWithRelationships emb;
+    
+    public PUDEntityA02() {
+        emb = new EmbeddableWithRelationships();
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getStrData() {
+        return strData;
+    }
+
+    public void setStrData(String strData) {
+        this.strData = strData;
+    }
+
+    public EmbeddableWithRelationships getEmb() {
+        return emb;
+    }
+
+    public void setEmb(EmbeddableWithRelationships emb) {
+        this.emb = emb;
+    }
+
+    @Override
+    public String toString() {
+        return "PUDEntityA02 [id=" + id + ", strData=" + strData + ", emb="
+            + emb + "]";
+    }
+    
+    
+}

Propchange: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityA02.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityAE01.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityAE01.java?rev=1636422&view=auto
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityAE01.java (added)
+++ openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityAE01.java Mon Nov  3 19:23:30 2014
@@ -0,0 +1,128 @@
+/*
+ * 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.cascade.pudefault;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.persistence.Basic;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+
+@Entity
+public class PUDEntityAE01 {
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    private int id;
+    
+    @Basic
+    private String strData;
+    
+    @ManyToMany
+    private Collection<PUDEntityB> colM2M;
+    
+    @OneToMany
+    private Collection<PUDEntityB> colO2M;
+    
+    @ManyToOne
+    private PUDEntityB m2o;
+    
+    @OneToOne
+    private PUDEntityB o2o;
+    
+    @Embedded
+    private AnEmbeddable ane;
+    
+    public PUDEntityAE01() {
+        colM2M = new ArrayList<PUDEntityB>();
+        colO2M = new ArrayList<PUDEntityB>();
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getStrData() {
+        return strData;
+    }
+
+    public void setStrData(String strData) {
+        this.strData = strData;
+    }
+
+    public Collection<PUDEntityB> getColM2M() {
+        return colM2M;
+    }
+
+    public void setColM2M(Collection<PUDEntityB> colM2M) {
+        this.colM2M = colM2M;
+    }
+
+    public Collection<PUDEntityB> getColO2M() {
+        return colO2M;
+    }
+
+    public void setColO2M(Collection<PUDEntityB> colO2M) {
+        this.colO2M = colO2M;
+    }
+
+    public PUDEntityB getM2o() {
+        return m2o;
+    }
+
+    public void setM2o(PUDEntityB m2o) {
+        this.m2o = m2o;
+    }
+
+    public PUDEntityB getO2o() {
+        return o2o;
+    }
+
+    public void setO2o(PUDEntityB o2o) {
+        this.o2o = o2o;
+    }
+
+    public AnEmbeddable getAne() {
+        return ane;
+    }
+
+    public void setAne(AnEmbeddable ane) {
+        this.ane = ane;
+    }
+
+    @Override
+    public String toString() {
+        return "PUDEntityAE01 [id=" + id + ", strData=" + strData + ", colM2M="
+            + colM2M + ", colO2M=" + colO2M + ", m2o=" + m2o + ", o2o=" + o2o
+            + ", ane=" + ane + "]";
+    }
+    
+    
+}

Propchange: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityAE01.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityB.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityB.java?rev=1636422&view=auto
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityB.java (added)
+++ openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityB.java Mon Nov  3 19:23:30 2014
@@ -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.cascade.pudefault;
+
+import javax.persistence.Basic;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity
+public class PUDEntityB {
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    private int id;
+    
+    @Basic
+    private String strData;
+    
+    public PUDEntityB() {
+        
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getStrData() {
+        return strData;
+    }
+
+    public void setStrData(String strData) {
+        this.strData = strData;
+    }
+
+    @Override
+    public String toString() {
+        return "PUDEntityB [id=" + id + ", strData=" + strData + "]";
+    }
+    
+    
+}

Propchange: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/PUDEntityB.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/TestNoPUDefaultCascadePersist.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/TestNoPUDefaultCascadePersist.java?rev=1636422&view=auto
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/TestNoPUDefaultCascadePersist.java (added)
+++ openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/TestNoPUDefaultCascadePersist.java Mon Nov  3 19:23:30 2014
@@ -0,0 +1,271 @@
+/*
+ * 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.cascade.pudefault;
+
+import javax.persistence.EntityManager;
+
+import org.apache.openjpa.persistence.test.SingleEMFTestCase;
+
+public class TestNoPUDefaultCascadePersist extends SingleEMFTestCase {
+    public void setUp() throws Exception {
+        super.setUp(PUDEntityA01.class, PUDEntityAE01.class, PUDEntityB.class, AnEmbeddable.class,
+            CLEAR_TABLES);
+    }
+    
+    
+    public void testPUDefaultCascadePersistOverM2M() {
+        EntityManager em = emf.createEntityManager();
+        
+        PUDEntityA01 entity = null;
+        try {
+            em.getTransaction().begin();
+            
+            entity = new PUDEntityA01();
+            entity.setStrData("PUDEntityA01");
+             
+            for (int i = 0; i < 10; i++) {
+                PUDEntityB b = new PUDEntityB();
+                b.setStrData("B");
+                entity.getColM2M().add(b);
+            }
+            
+            em.persist(entity);
+            try {
+                em.getTransaction().commit();
+                fail("No Exception thrown.");
+            } catch (Exception e) {
+                // Expected
+            }
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+            em.close();
+        }      
+    }
+    
+    public void testPUDefaultCascadePersistOverO2M() {
+        EntityManager em = emf.createEntityManager();
+        
+        PUDEntityA01 entity = null;
+        try {
+            em.getTransaction().begin();
+            
+            entity = new PUDEntityA01();
+            entity.setStrData("PUDEntityA01");
+             
+            for (int i = 0; i < 10; i++) {
+                PUDEntityB b = new PUDEntityB();
+                b.setStrData("B");
+                entity.getColO2M().add(b);
+            }
+            
+            em.persist(entity);
+            try {
+                em.getTransaction().commit();
+                fail("No Exception thrown.");
+            } catch (Exception e) {
+                // Expected
+            }
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+            em.close();
+        }      
+    }
+    
+    public void testPUDefaultCascadePersistOverO2O() {
+        EntityManager em = emf.createEntityManager();
+        
+        PUDEntityA01 entity = null;
+        try {
+            em.getTransaction().begin();
+            
+            entity = new PUDEntityA01();
+            entity.setStrData("PUDEntityA01");
+            
+            PUDEntityB b = new PUDEntityB();
+            b.setStrData("B");
+            entity.setO2o(b);
+            
+            em.persist(entity);
+            try {
+                em.getTransaction().commit();
+                fail("No Exception thrown.");
+            } catch (Exception e) {
+                // Expected
+            }
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+            em.close();
+        }      
+    }
+    
+    public void testPUDefaultCascadePersistOverM2O() {
+        EntityManager em = emf.createEntityManager();
+        
+        PUDEntityA01 entity = null;
+        try {
+            em.getTransaction().begin();
+            
+            entity = new PUDEntityA01();
+            entity.setStrData("PUDEntityA01");
+            
+            PUDEntityB b = new PUDEntityB();
+            b.setStrData("B");
+            entity.setM2o(b);
+            
+            em.persist(entity);
+            try {
+                em.getTransaction().commit();
+                fail("No Exception thrown.");
+            } catch (Exception e) {
+                // Expected
+            }
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+            em.close();
+        }      
+    }
+    
+    public void testPUDefaultCascadePersistOverM2MWithEmbed() {
+        EntityManager em = emf.createEntityManager();
+        
+        PUDEntityAE01 entity = null;
+        try {
+            em.getTransaction().begin();
+            
+            entity = new PUDEntityAE01();
+            entity.setStrData("PUDEntityAE01");
+             
+            for (int i = 0; i < 10; i++) {
+                PUDEntityB b = new PUDEntityB();
+                b.setStrData("B");
+                entity.getColM2M().add(b);
+            }
+            
+            em.persist(entity);
+            try {
+                em.getTransaction().commit();
+                fail("No Exception thrown.");
+            } catch (Exception e) {
+                // Expected
+            }
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+            em.close();
+        }      
+    }
+    
+    public void testPUDefaultCascadePersistOverO2MWithEmbed() {
+        EntityManager em = emf.createEntityManager();
+        
+        PUDEntityAE01 entity = null;
+        try {
+            em.getTransaction().begin();
+            
+            entity = new PUDEntityAE01();
+            entity.setStrData("PUDEntityAE01");
+             
+            for (int i = 0; i < 10; i++) {
+                PUDEntityB b = new PUDEntityB();
+                b.setStrData("B");
+                entity.getColO2M().add(b);
+            }
+            
+            em.persist(entity);
+            try {
+                em.getTransaction().commit();
+                fail("No Exception thrown.");
+            } catch (Exception e) {
+                // Expected
+            }
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+            em.close();
+        }      
+    }
+    
+    public void testPUDefaultCascadePersistOverO2OWithEmbed() {
+        EntityManager em = emf.createEntityManager();
+        
+        PUDEntityAE01 entity = null;
+        try {
+            em.getTransaction().begin();
+            
+            entity = new PUDEntityAE01();
+            entity.setStrData("PUDEntityAE01");
+            
+            PUDEntityB b = new PUDEntityB();
+            b.setStrData("B");
+            entity.setO2o(b);
+            
+            em.persist(entity);
+            try {
+                em.getTransaction().commit();
+                fail("No Exception thrown.");
+            } catch (Exception e) {
+                // Expected
+            }
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+            em.close();
+        }      
+    }
+    
+    public void testPUDefaultCascadePersistOverM2OWithEmbed() {
+        EntityManager em = emf.createEntityManager();
+        
+        PUDEntityAE01 entity = null;
+        try {
+            em.getTransaction().begin();
+            
+            entity = new PUDEntityAE01();
+            entity.setStrData("PUDEntityAE01");
+            
+            PUDEntityB b = new PUDEntityB();
+            b.setStrData("B");
+            entity.setM2o(b);
+            
+            em.persist(entity);
+            try {
+                em.getTransaction().commit();
+                fail("No Exception thrown.");
+            } catch (Exception e) {
+                // Expected
+            }
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+            em.close();
+        }      
+    }
+}

Propchange: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/TestNoPUDefaultCascadePersist.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/TestPUDefaultCascadePersist.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/TestPUDefaultCascadePersist.java?rev=1636422&view=auto
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/TestPUDefaultCascadePersist.java (added)
+++ openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/TestPUDefaultCascadePersist.java Mon Nov  3 19:23:30 2014
@@ -0,0 +1,504 @@
+/*
+ * 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.cascade.pudefault;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.apache.openjpa.persistence.test.SingleEMFTestCase;
+
+public class TestPUDefaultCascadePersist extends SingleEMFTestCase {
+    private EntityManagerFactory emf = null;
+    public void setUp() throws Exception {
+        super.setUp();
+        emf = OpenJPAPersistence.
+                createEntityManagerFactory("TestPUDefaultCascadePersist", 
+                    "org/apache/openjpa/persistence/cascade/pudefault/META-INF/persistence.xml");
+//        super.setUp(PUDEntityA01.class, PUDEntityB.class,
+//            "org/apache/openjpa/persistence/cascade/pudefault/META-INF/cascadepersistorm.xml",
+//            CLEAR_TABLES);
+    }
+    
+    public void tearDown() throws Exception {
+        super.tearDown();
+        emf.close();
+    }
+    
+    public void testPUDefaultCascadePersistOverM2M() {
+        EntityManager em = emf.createEntityManager();
+        
+        PUDEntityA01 entity = null;
+        try {
+            em.getTransaction().begin();
+            
+            entity = new PUDEntityA01();
+            entity.setStrData("PUDEntityA01");
+             
+            for (int i = 0; i < 10; i++) {
+                PUDEntityB b = new PUDEntityB();
+                b.setStrData("B");
+                entity.getColM2M().add(b);
+            }
+            
+            em.persist(entity);
+            em.getTransaction().commit();
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }
+               
+        em.close();
+        em = emf.createEntityManager();
+        
+        try {
+            PUDEntityA01 f_entity = em.find(PUDEntityA01.class, entity.getId());
+            assertNotNull(f_entity);
+            assertNotSame(entity, f_entity);
+            assertEquals(10, f_entity.getColM2M().size());
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }       
+    }
+    
+    public void testPUDefaultCascadePersistOverO2M() {
+        EntityManager em = emf.createEntityManager();
+        
+        PUDEntityA01 entity = null;
+        try {
+            em.getTransaction().begin();
+            
+            entity = new PUDEntityA01();
+            entity.setStrData("PUDEntityA01");
+             
+            for (int i = 0; i < 10; i++) {
+                PUDEntityB b = new PUDEntityB();
+                b.setStrData("B");
+                entity.getColO2M().add(b);
+            }
+            
+            em.persist(entity);
+            em.getTransaction().commit();
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }
+               
+        em.close();
+        em = emf.createEntityManager();
+        
+        try {
+            PUDEntityA01 f_entity = em.find(PUDEntityA01.class, entity.getId());
+            assertNotNull(f_entity);
+            assertNotSame(entity, f_entity);
+            assertEquals(10, f_entity.getColO2M().size());
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }       
+    }
+    
+    public void testPUDefaultCascadePersistOverO2O() {
+        EntityManager em = emf.createEntityManager();
+        
+        PUDEntityA01 entity = null;
+        try {
+            em.getTransaction().begin();
+            
+            entity = new PUDEntityA01();
+            entity.setStrData("PUDEntityA01");
+            
+            PUDEntityB b = new PUDEntityB();
+            b.setStrData("B");
+            entity.setO2o(b);
+            
+            em.persist(entity);
+            em.getTransaction().commit();
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }
+               
+        em.close();
+        em = emf.createEntityManager();
+        
+        try {
+            PUDEntityA01 f_entity = em.find(PUDEntityA01.class, entity.getId());
+            assertNotNull(f_entity);
+            assertNotSame(entity, f_entity);
+            assertNotNull(entity.getO2o());
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }       
+    }
+    
+    public void testPUDefaultCascadePersistOverM2O() {
+        EntityManager em = emf.createEntityManager();
+        
+        PUDEntityA01 entity = null;
+        try {
+            em.getTransaction().begin();
+            
+            entity = new PUDEntityA01();
+            entity.setStrData("PUDEntityA01");
+            
+            PUDEntityB b = new PUDEntityB();
+            b.setStrData("B");
+            entity.setM2o(b);
+            
+            em.persist(entity);
+            em.getTransaction().commit();
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }
+               
+        em.close();
+        em = emf.createEntityManager();
+        
+        try {
+            PUDEntityA01 f_entity = em.find(PUDEntityA01.class, entity.getId());
+            assertNotNull(f_entity);
+            assertNotSame(entity, f_entity);
+            assertNotNull(entity.getM2o());
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }       
+    }
+    
+    
+    
+    public void testPUDefaultCascadePersistOverM2MWithEmbed() {
+        EntityManager em = emf.createEntityManager();
+        
+        PUDEntityAE01 entity = null;
+        try {
+            em.getTransaction().begin();
+            
+            entity = new PUDEntityAE01();
+            entity.setStrData("PUDEntityAE01");
+             
+            for (int i = 0; i < 10; i++) {
+                PUDEntityB b = new PUDEntityB();
+                b.setStrData("B");
+                entity.getColM2M().add(b);
+            }
+            
+            em.persist(entity);
+            em.getTransaction().commit();
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }
+               
+        em.close();
+        em = emf.createEntityManager();
+        
+        try {
+            PUDEntityAE01 f_entity = em.find(PUDEntityAE01.class, entity.getId());
+            assertNotNull(f_entity);
+            assertNotSame(entity, f_entity);
+            assertEquals(10, f_entity.getColM2M().size());
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }       
+    }
+    
+    public void testPUDefaultCascadePersistOverO2MWithEmbed() {
+        EntityManager em = emf.createEntityManager();
+        
+        PUDEntityAE01 entity = null;
+        try {
+            em.getTransaction().begin();
+            
+            entity = new PUDEntityAE01();
+            entity.setStrData("PUDEntityAE01");
+             
+            for (int i = 0; i < 10; i++) {
+                PUDEntityB b = new PUDEntityB();
+                b.setStrData("B");
+                entity.getColO2M().add(b);
+            }
+            
+            em.persist(entity);
+            em.getTransaction().commit();
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }
+               
+        em.close();
+        em = emf.createEntityManager();
+        
+        try {
+            PUDEntityAE01 f_entity = em.find(PUDEntityAE01.class, entity.getId());
+            assertNotNull(f_entity);
+            assertNotSame(entity, f_entity);
+            assertEquals(10, f_entity.getColO2M().size());
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }       
+    }
+    
+    public void testPUDefaultCascadePersistOverO2OWithEmbed() {
+        EntityManager em = emf.createEntityManager();
+        
+        PUDEntityAE01 entity = null;
+        try {
+            em.getTransaction().begin();
+            
+            entity = new PUDEntityAE01();
+            entity.setStrData("PUDEntityAE01");
+            
+            PUDEntityB b = new PUDEntityB();
+            b.setStrData("B");
+            entity.setO2o(b);
+            
+            em.persist(entity);
+            em.getTransaction().commit();
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }
+               
+        em.close();
+        em = emf.createEntityManager();
+        
+        try {
+            PUDEntityAE01 f_entity = em.find(PUDEntityAE01.class, entity.getId());
+            assertNotNull(f_entity);
+            assertNotSame(entity, f_entity);
+            assertNotNull(entity.getO2o());
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }       
+    }
+    
+    public void testPUDefaultCascadePersistOverM2OWithEmbed() {
+        EntityManager em = emf.createEntityManager();
+        
+        PUDEntityAE01 entity = null;
+        try {
+            em.getTransaction().begin();
+            
+            entity = new PUDEntityAE01();
+            entity.setStrData("PUDEntityAE01");
+            
+            PUDEntityB b = new PUDEntityB();
+            b.setStrData("B");
+            entity.setM2o(b);
+            
+            em.persist(entity);
+            em.getTransaction().commit();
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }
+               
+        em.close();
+        em = emf.createEntityManager();
+        
+        try {
+            PUDEntityAE01 f_entity = em.find(PUDEntityAE01.class, entity.getId());
+            assertNotNull(f_entity);
+            assertNotSame(entity, f_entity);
+            assertNotNull(entity.getM2o());
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }       
+    }
+    
+    
+    public void testPUDefaultCascadePersistOverM2MEmbbedRel() {
+        EntityManager em = emf.createEntityManager();
+        
+        PUDEntityA02 entity = null;
+        try {
+            em.getTransaction().begin();
+            
+            entity = new PUDEntityA02();
+            entity.setStrData("PUDEntityA02");
+             
+            for (int i = 0; i < 10; i++) {
+                PUDEntityB b = new PUDEntityB();
+                b.setStrData("B");
+                entity.getEmb().getColM2M().add(b);
+            }
+            
+            em.persist(entity);
+            em.getTransaction().commit();
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }
+               
+        em.close();
+        em = emf.createEntityManager();
+        
+        try {
+            PUDEntityA02 f_entity = em.find(PUDEntityA02.class, entity.getId());
+            assertNotNull(f_entity);
+            assertNotSame(entity, f_entity);
+            assertEquals(10, f_entity.getEmb().getColM2M().size());
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }       
+    }
+    
+    public void testPUDefaultCascadePersistOverO2MEmbbedRel() {
+        EntityManager em = emf.createEntityManager();
+        
+        PUDEntityA02 entity = null;
+        try {
+            em.getTransaction().begin();
+            
+            entity = new PUDEntityA02();
+            entity.setStrData("PUDEntityA02");
+             
+            for (int i = 0; i < 10; i++) {
+                PUDEntityB b = new PUDEntityB();
+                b.setStrData("B");
+                entity.getEmb().getColO2M().add(b);
+            }
+            
+            em.persist(entity);
+            em.getTransaction().commit();
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }
+               
+        em.close();
+        em = emf.createEntityManager();
+        
+        try {
+            PUDEntityA02 f_entity = em.find(PUDEntityA02.class, entity.getId());
+            assertNotNull(f_entity);
+            assertNotSame(entity, f_entity);
+            assertEquals(10, f_entity.getEmb().getColO2M().size());
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }       
+    }
+    
+    public void testPUDefaultCascadePersistOverO2OEmbbedRel() {
+        EntityManager em = emf.createEntityManager();
+        
+        PUDEntityA02 entity = null;
+        try {
+            em.getTransaction().begin();
+            
+            entity = new PUDEntityA02();
+            entity.setStrData("PUDEntityA02");
+            
+            PUDEntityB b = new PUDEntityB();
+            b.setStrData("B");
+            entity.getEmb().setO2o(b);
+            
+            em.persist(entity);
+            em.getTransaction().commit();
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }
+               
+        em.close();
+        em = emf.createEntityManager();
+        
+        try {
+            PUDEntityA02 f_entity = em.find(PUDEntityA02.class, entity.getId());
+            assertNotNull(f_entity);
+            assertNotSame(entity, f_entity);
+            assertNotNull(entity.getEmb().getO2o());
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }       
+    }
+    
+    public void testPUDefaultCascadePersistOverM2OEmbbedRel() {
+        EntityManager em = emf.createEntityManager();
+        
+        PUDEntityA02 entity = null;
+        try {
+            em.getTransaction().begin();
+            
+            entity = new PUDEntityA02();
+            entity.setStrData("PUDEntityA02");
+            
+            PUDEntityB b = new PUDEntityB();
+            b.setStrData("B");
+            entity.getEmb().setM2o(b);
+            
+            em.persist(entity);
+            em.getTransaction().commit();
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }
+               
+        em.close();
+        em = emf.createEntityManager();
+        
+        try {
+            PUDEntityA02 f_entity = em.find(PUDEntityA02.class, entity.getId());
+            assertNotNull(f_entity);
+            assertNotSame(entity, f_entity);
+            assertNotNull(entity.getEmb().getM2o());
+        } finally {
+            if (em.getTransaction().isActive()) {
+                em.getTransaction().rollback();
+            }
+        }       
+    }
+    
+
+}

Propchange: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cascade/pudefault/TestPUDefaultCascadePersist.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/cascade/pudefault/META-INF/cascadepersistorm.xml
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/cascade/pudefault/META-INF/cascadepersistorm.xml?rev=1636422&view=auto
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/cascade/pudefault/META-INF/cascadepersistorm.xml (added)
+++ openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/cascade/pudefault/META-INF/cascadepersistorm.xml Mon Nov  3 19:23:30 2014
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
+    version="1.0">
+    <persistence-unit-metadata>
+        <persistence-unit-defaults>
+            <cascade-persist/>
+        </persistence-unit-defaults>
+    </persistence-unit-metadata>
+</entity-mappings>
\ No newline at end of file

Propchange: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/cascade/pudefault/META-INF/cascadepersistorm.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/cascade/pudefault/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/cascade/pudefault/META-INF/persistence.xml?rev=1636422&view=auto
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/cascade/pudefault/META-INF/persistence.xml (added)
+++ openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/cascade/pudefault/META-INF/persistence.xml Mon Nov  3 19:23:30 2014
@@ -0,0 +1,38 @@
+<!--
+ 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.   
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" 
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" 
+    version="1.0">
+    <persistence-unit name="TestPUDefaultCascadePersist" transaction-type="RESOURCE_LOCAL">
+        <!--  <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> -->
+        <mapping-file>org/apache/openjpa/persistence/cascade/pudefault/META-INF/cascadepersistorm.xml</mapping-file>
+        <class>org.apache.openjpa.persistence.cascade.pudefault.PUDEntityA01</class>
+        <class>org.apache.openjpa.persistence.cascade.pudefault.PUDEntityAE01</class>
+        <class>org.apache.openjpa.persistence.cascade.pudefault.PUDEntityA02</class>
+        <class>org.apache.openjpa.persistence.cascade.pudefault.PUDEntityB</class>
+        <class>org.apache.openjpa.persistence.cascade.pudefault.AnEmbeddable</class>
+        <class>org.apache.openjpa.persistence.cascade.pudefault.EmbeddableWithRelationships</class>
+        <properties>
+            <property name="openjpa.ConnectionFactoryProperties" value="MaxActive=110, MaxIdle=10, ValidationTimeout=50000, 
+                                                                     MaxCachedStatements=10, ValidationSQL='', MaxWait=10000, TestOnBorrow=true" />
+            <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)" />
+        </properties>
+    </persistence-unit>
+</persistence>

Propchange: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/cascade/pudefault/META-INF/persistence.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message