openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwo...@apache.org
Subject svn commit: r814739 - in /openjpa/trunk: openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compatible/ openjpa-project/src/doc/manual/
Date Mon, 14 Sep 2009 17:20:49 GMT
Author: dwoods
Date: Mon Sep 14 17:20:48 2009
New Revision: 814739

URL: http://svn.apache.org/viewvc?rev=814739&view=rev
Log:
OPENJPA-1214 Testcase to demonstrate RelationFieldStrategy behaviour differences between OpenJPA
1.x and 2.0.  Testcase contributed by Tim McConnell.  Doc updates by Donald Woods.

Added:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compatible/
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compatible/EmbeddableSuper.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compatible/EmbeddableSuperSub.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compatible/TestEmbeddableSuperclass.java
  (with props)
Modified:
    openjpa/trunk/openjpa-project/src/doc/manual/migration_considerations.xml

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compatible/EmbeddableSuper.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compatible/EmbeddableSuper.java?rev=814739&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compatible/EmbeddableSuper.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compatible/EmbeddableSuper.java
Mon Sep 14 17:20:48 2009
@@ -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.compatible;
+
+
+import javax.persistence.*;
+
+@MappedSuperclass
+public class EmbeddableSuper {
+
+    @Id
+    @GeneratedValue
+    @Column(name = "ID")
+    private long pk;
+
+    @Version
+    @Column(name = "SUPVERS")
+    private int version;
+
+    @Transient
+    private int trans;
+
+    @Lob
+    @Column(name = "CLOBVAL")
+    protected String clob;
+
+    public EmbeddableSuper() {
+    }
+
+    public long getPK() {
+        return this.pk;
+    }
+
+    public void setPK(long pk) {
+        this.pk = pk;
+    }
+
+    public int getTrans() {
+        return this.trans;
+    }
+
+    public void setTrans(int trans) {
+        this.trans = trans;
+    }
+
+    public String getClob() {
+        return this.clob;
+    }
+
+    public void setClob(String clob) {
+        this.clob = clob;
+    }
+
+    public int getVersion() {
+        return this.version;
+    }
+
+    public void setVersion(int version) {
+        this.version = version;
+    }
+}

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

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compatible/EmbeddableSuperSub.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compatible/EmbeddableSuperSub.java?rev=814739&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compatible/EmbeddableSuperSub.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compatible/EmbeddableSuperSub.java
Mon Sep 14 17:20:48 2009
@@ -0,0 +1,58 @@
+/*
+ * 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.compatible;
+
+
+import javax.persistence.*;
+
+@Entity
+@DiscriminatorColumn(name = "DISC")
+@AttributeOverrides({
+    @AttributeOverride(name = "clob", column = @Column(name = "CC")),
+    @AttributeOverride(name = "version", column = @Column(name = "VERSVAL"))
+})
+public class EmbeddableSuperSub
+    extends EmbeddableSuper {
+
+    @ManyToOne
+    private EmbeddableSuperSub sub;
+
+    @ManyToOne
+    // #####
+    private EmbeddableSuper sup;
+
+    public EmbeddableSuperSub() {
+    }
+
+    public EmbeddableSuperSub getSub() {
+        return this.sub;
+    }
+
+    public void setSub(EmbeddableSuperSub sub) {
+        this.sub = sub;
+    }
+
+    public EmbeddableSuper getSup() {
+        return this.sup;
+    }
+
+    public void setSup(EmbeddableSuper sup) {
+        this.sup = sup;
+    }
+}

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

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compatible/TestEmbeddableSuperclass.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compatible/TestEmbeddableSuperclass.java?rev=814739&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compatible/TestEmbeddableSuperclass.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compatible/TestEmbeddableSuperclass.java
Mon Sep 14 17:20:48 2009
@@ -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.compatible;
+
+import java.sql.Types;
+
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
+import org.apache.openjpa.jdbc.meta.ClassMapping;
+import org.apache.openjpa.jdbc.meta.FieldMapping;
+import org.apache.openjpa.jdbc.meta.strats.ClobValueHandler;
+import org.apache.openjpa.jdbc.meta.strats.EmbedFieldStrategy;
+import org.apache.openjpa.jdbc.meta.strats.FullClassStrategy;
+import org.apache.openjpa.jdbc.meta.strats.MaxEmbeddedClobFieldStrategy;
+import org.apache.openjpa.jdbc.meta.strats.NoneClassStrategy;
+import org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy;
+import org.apache.openjpa.jdbc.meta.strats.StringFieldStrategy;
+import org.apache.openjpa.jdbc.sql.DBDictionary;
+import org.apache.openjpa.meta.ValueStrategies;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.test.SingleEMFTestCase;
+
+/**
+ * <p>Test embeddable superclasses</p>
+ *
+ *
+ * <b>Compatible testcases</b> are used to test various backwards compatibility
scenarios between JPA 2.0 and JPA 1.2
+ * 
+ * <p>The following scenarios are tested:
+ * <ol>
+ * <li>RelationFieldStrategy
+ * </ol>
+ * <p> 
+ * <b>Note(s):</b>
+ * <ul>
+ * <li>The proper openjpa.Compatibility value(s) must be provided in order for the
testcase(s) to succeed
+ * </ul>
+ */
+public class TestEmbeddableSuperclass
+    extends SingleEMFTestCase {
+
+    public void setUp() {
+        setUp(EmbeddableSuper.class, EmbeddableSuperSub.class, CLEAR_TABLES);
+    }
+
+    public void testRelationMappings() {
+        JDBCConfiguration conf = (JDBCConfiguration) emf.getConfiguration();
+        ClassMapping cls = conf.getMappingRepositoryInstance().
+            getMapping(EmbeddableSuperSub.class, null, true);
+        FieldMapping fm = cls.getFieldMapping("sub");
+        assertTrue(fm.getStrategy() instanceof RelationFieldStrategy);
+
+        fm = cls.getFieldMapping("sup");
+        // OPENJPA-1214 - OpenJPA 2 returns a EmbedFieldStrategy instead of a 
+        // RelationFieldStrategy as in prior releases.
+        // assertTrue(fm.getStrategy() instanceof RelationFieldStrategy);
+        assertTrue(fm.getStrategy() instanceof EmbedFieldStrategy);
+    } 
+}
+

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

Modified: openjpa/trunk/openjpa-project/src/doc/manual/migration_considerations.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-project/src/doc/manual/migration_considerations.xml?rev=814739&r1=814738&r2=814739&view=diff
==============================================================================
--- openjpa/trunk/openjpa-project/src/doc/manual/migration_considerations.xml (original)
+++ openjpa/trunk/openjpa-project/src/doc/manual/migration_considerations.xml Mon Sep 14 17:20:48
2009
@@ -157,5 +157,28 @@
                 will not be disabled automatically.
             </para>
         </section>
+    	<section id="internal_differences">
+    		<title>
+    			Internal Behavioral Differences
+    		</title>
+    		<para>
+    		The following sections indicate internal changes between
+    		OpenJPA 1.x.x releases and the 2.0 release. As these are
+                internal implementation classes, no changes to applications
+                should be required.
+    		</para>
+    		<section id="getStrategy">
+    			<title>
+    				FieldMapping.getStrategy()
+    			</title>
+    			<para>
+    				The FieldMapping.getStrategy() in OpenJPA 1.x
+				returned an instance of RelationFieldStrategy
+				for embded super classes, but will now return an
+				EmbedFieldStrategy.  See OPENJPA-1214 for an
+				example test case demonstrating the change.
+			</para>
+		</section>
+        </section>
     </section>
 </appendix>



Mime
View raw message