openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r799754 - in /openjpa/trunk: openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/ openjpa-persistence-jdbc/src/test/resources/META-INF/ openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/ openjpa-pe...
Date Fri, 31 Jul 2009 22:04:14 GMT
Author: mikedd
Date: Fri Jul 31 22:04:13 2009
New Revision: 799754

URL: http://svn.apache.org/viewvc?rev=799754&view=rev
Log:
OPENJPA-1174:
Ensure lazy hint from mapping-file is handled the same as an annotation
Submitted by: Ravi Palacherla

Added:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Country.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Country1.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Embed.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Security.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Security1.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/TestXMLPersistenceMetaDataParser.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/orm.xml
  (with props)
Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Country.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Country.java?rev=799754&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Country.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Country.java
Fri Jul 31 22:04:13 2009
@@ -0,0 +1,54 @@
+/*
+ * 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;
+
+import javax.persistence.*;
+@Entity
+@Table(name="COUNTRY1")
+public class Country {
+    @Id
+    @Column(name="COUNTRY_ID")
+    private long id;
+    
+    @Column(name="NAME")
+    private String name;
+
+    public Country() {
+        super();
+    }
+
+    public Country(long id, String name) {
+        super();
+        this.id = id;
+        this.name = name;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}
+

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

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Country1.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Country1.java?rev=799754&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Country1.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Country1.java
Fri Jul 31 22:04:13 2009
@@ -0,0 +1,49 @@
+/*
+ * 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;
+
+public class Country1 {
+
+    private long id;
+
+    private String name;
+
+    public Country1() {
+        super();
+    }
+
+    public Country1(long id, String name) {
+        super();
+        this.id = id;
+        this.name = name;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}
+

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

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Embed.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Embed.java?rev=799754&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Embed.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Embed.java
Fri Jul 31 22:04:13 2009
@@ -0,0 +1,44 @@
+/*
+ * 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;
+import javax.persistence.*;
+
+@Embeddable
+public class Embed {
+    
+    public Embed() {
+        
+    }
+    
+    public Embed(String symbol) {
+        this.symbol=symbol;
+    }
+    
+    private String symbol;
+
+    public String getSymbol() {
+        return symbol;
+    }
+
+    public void setSymbol(String symbol) {
+        this.symbol = symbol;
+    }
+    
+}
+

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

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Security.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Security.java?rev=799754&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Security.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Security.java
Fri Jul 31 22:04:13 2009
@@ -0,0 +1,67 @@
+/*
+ * 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;
+import javax.persistence.*;
+
+@Entity
+@Table(name="SECURITY1")
+public class Security {
+    @Id
+    @Column(name="SECURITY_ID")
+    private long id;
+    
+    @Embedded
+    @Column(name="SYMBOL")
+    private Embed symbol;
+    
+    @ManyToOne(optional=false,fetch=FetchType.LAZY) 
+    @JoinColumn(name="COUNTRY_ID")
+    private Country country;
+
+    public Security() {
+        super();
+    }
+
+    public Security(long id, Embed symbol) {
+        super();
+        this.id = id;
+        this.symbol = symbol;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public Country getCountry() {
+        return country;
+    }
+
+    public void setCountry(Country c) {
+        this.country = c;
+    }
+
+    public Embed getSymbol() {
+        return symbol;
+    }
+
+    public void setSymbol(Embed symbol) {
+        this.symbol = symbol;
+    }
+}
+

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

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Security1.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Security1.java?rev=799754&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Security1.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/Security1.java
Fri Jul 31 22:04:13 2009
@@ -0,0 +1,59 @@
+/*
+ * 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;
+
+public class Security1 {
+
+    private long id;
+
+    private Embed symbol;
+    
+    private Country1 country;
+
+    public Security1() {
+        super();
+    }
+
+    public Security1(long id, Embed symbol) {
+        super();
+        this.id = id;
+        this.symbol = symbol;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public Country1 getCountry1() {
+        return country;
+    }
+
+    public void setCountry1(Country1 c) {
+        this.country = c;
+    }
+
+    public Embed getSymbol() {
+        return symbol;
+    }
+
+    public void setSymbol(Embed symbol) {
+        this.symbol = symbol;
+    }
+}
+

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

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/TestXMLPersistenceMetaDataParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/TestXMLPersistenceMetaDataParser.java?rev=799754&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/TestXMLPersistenceMetaDataParser.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/TestXMLPersistenceMetaDataParser.java
Fri Jul 31 22:04:13 2009
@@ -0,0 +1,161 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
+import org.apache.openjpa.jdbc.meta.ClassMapping;
+import org.apache.openjpa.jdbc.meta.FieldMapping;
+import org.apache.openjpa.persistence.test.SQLListenerTestCase;
+import javax.persistence.*;
+
+public class TestXMLPersistenceMetaDataParser extends SQLListenerTestCase {
+
+    public void setUp() {
+        super.setUp(CLEAR_TABLES, Security1.class, Country1.class,
+            Security.class, Country.class);
+    }
+
+    protected String getPersistenceUnitName() {
+        return "test-persistence-xml-orm";
+    }
+
+    public void testManyToOneLazyFetch() {
+
+        EntityManager em = emf.createEntityManager();
+
+        // initialize objects
+        long aI_sid = 148007244;
+        long aUS_sid = 1;
+
+        Security1 aI_security = new Security1(aI_sid, new Embed("XYZ"));
+        Country1 aUS_country = new Country1(aUS_sid, "USA");
+        aI_security.setCountry1(aUS_country);
+
+        Security aI_securityAnn = new Security(aI_sid, new Embed("XYZ"));
+        Country aUS_countryAnn = new Country(aUS_sid, "USA");
+        aI_securityAnn.setCountry(aUS_countryAnn);
+
+        em.getTransaction().begin();
+        em.persist(aI_security);
+        em.persist(aUS_country);
+        em.getTransaction().commit();
+        em.clear();
+
+        ArrayList<String> XMLsql = new ArrayList<String>();
+        ArrayList<String> Annsql = new ArrayList<String>();
+
+        super.sql = new ArrayList<String>();
+        aUS_country = em.find(Country1.class, aUS_sid);
+        Iterator itr = super.sql.iterator();
+        while (itr.hasNext()) {
+            XMLsql.add((String) itr.next());
+        }
+        super.sql.clear();
+
+        super.sql = new ArrayList<String>();
+        aUS_countryAnn = em.find(Country.class, aUS_sid);
+        itr = super.sql.iterator();
+        while (itr.hasNext()) {
+            Annsql.add((String) itr.next());
+        }
+        super.sql.clear();
+        compareselectSQLs(Annsql, XMLsql);
+        Annsql.clear();
+        XMLsql.clear();
+
+        super.sql = new ArrayList<String>();
+        aI_security = em.find(Security1.class, aI_sid);
+        itr = super.sql.iterator();
+        while (itr.hasNext()) {
+            XMLsql.add((String) itr.next());
+        }
+        super.sql.clear();
+
+        super.sql = new ArrayList<String>();
+        aI_securityAnn = em.find(Security.class, aI_sid);
+        itr = super.sql.iterator();
+        while (itr.hasNext()) {
+            Annsql.add((String) itr.next());
+        }
+        super.sql.clear();
+        compareselectSQLs(Annsql, XMLsql);
+        Annsql.clear();
+        XMLsql.clear();
+
+        super.sql = new ArrayList<String>();
+        Country1 aUS_country1 = aI_security.getCountry1();
+        itr = super.sql.iterator();
+        while (itr.hasNext()) {
+            XMLsql.add((String) itr.next());
+        }
+        super.sql.clear();
+
+        super.sql = new ArrayList<String>();
+        Country aUS_country2 = aI_securityAnn.getCountry();
+        itr = super.sql.iterator();
+        while (itr.hasNext()) {
+            Annsql.add((String) itr.next());
+        }
+        super.sql.clear();
+        compareselectSQLs(Annsql, XMLsql);
+        Annsql.clear();
+        XMLsql.clear();
+
+        // Close
+        em.close();
+
+    }
+
+    private void printArrayList(ArrayList aList) {
+        Iterator itr = aList.iterator();
+        while (itr.hasNext()) {
+            System.out.println(itr.next());
+        }
+    }
+
+    /*
+     * This method is not a genralized method that can compare any select
+     * statement. It is customized only for this testcase.
+     */
+    private void compareselectSQLs(List<String> a, List<String> b) {
+        assertEquals(a.size(), b.size());
+        for (int i = 0; i < a.size(); i++) {
+            // assertEquals(a.get(i), b.get(i));
+            String aStr = a.get(i);
+            String bStr = b.get(i);
+            String[] aArr =
+                (aStr.substring(aStr.indexOf("SELECT ") + 7, aStr
+                    .indexOf(" FROM "))).split(",");
+            String[] bArr =
+                (bStr.substring(bStr.indexOf("SELECT ") + 7, bStr
+                    .indexOf(" FROM "))).split(",");
+            Arrays.sort(aArr);
+            Arrays.sort(bArr);
+            assertTrue(Arrays.equals(aArr, bArr));
+            assertEquals(aStr.substring(aStr.indexOf("FROM ") + 5), bStr
+                .substring(aStr.indexOf("FROM ") + 5));
+        }
+    }
+
+}

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

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml?rev=799754&r1=799753&r2=799754&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml Fri
Jul 31 22:04:13 2009
@@ -49,6 +49,7 @@
         <mapping-file>org/apache/openjpa/persistence/jdbc/order/order-orm-2.xml</mapping-file>
         <mapping-file>org/apache/openjpa/persistence/jdbc/order/order-orm-3.xml</mapping-file>
         <mapping-file>org/apache/openjpa/persistence/inheritance/orm.xml</mapping-file>
+        <mapping-file>org/apache/openjpa/persistence/orm.xml</mapping-file>
         <properties>
             <property name="openjpa.jdbc.SynchronizeMappings"
                 value="buildSchema(ForeignKeys=true)"/>
@@ -174,6 +175,19 @@
         </properties>
     </persistence-unit>
     
+    <persistence-unit name="test-persistence-xml-orm">
+        <mapping-file>org/apache/openjpa/persistence/orm.xml</mapping-file>
+        <class>org.apache.openjpa.persistence.Security1</class>
+        <class>org.apache.openjpa.persistence.Country1</class>
+        <class>org.apache.openjpa.persistence.Security</class>
+        <class>org.apache.openjpa.persistence.Country</class>
+        <class>org.apache.openjpa.persistence.Embed</class>
+        <properties>
+            <property name="openjpa.DynamicEnhancementAgent" 
+                value="false"/> 
+        </properties>
+    </persistence-unit>
+    
     <persistence-unit name="PreparedQuery" transaction-type="RESOURCE_LOCAL">
         <description>PU for PreparedQueryCache testing</description>
         

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/orm.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/orm.xml?rev=799754&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/orm.xml
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/orm.xml
Fri Jul 31 22:04:13 2009
@@ -0,0 +1,55 @@
+<?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">
+    <package>org.apache.openjpa.persistence</package>
+    <entity class="Security1">
+        <table name="SECURITY1" />
+        <attributes>
+            <id name="id">
+                <column name="SECURITY_ID" />
+            </id>
+            <many-to-one name="country" optional="false" fetch="LAZY">
+                <join-column name="COUNTRY_ID" />
+            </many-to-one>
+            <embedded name="symbol" />
+        </attributes>
+    </entity>
+    <entity class="Country1">
+        <table name="COUNTRY1" />
+        <attributes>
+            <id name="id">
+                <column name="COUNTRY_ID" />
+            </id>
+            <basic name="name">
+                <column name="NAME" />
+            </basic>
+        </attributes>
+    </entity>
+    <embeddable class="Embed">
+        <attributes>
+        <basic name="symbol">
+                <column name="SYMBOL" />
+            </basic>
+        </attributes>
+    </embeddable>
+</entity-mappings>
\ No newline at end of file

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/orm.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java?rev=799754&r1=799753&r2=799754&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java
Fri Jul 31 22:04:13 2009
@@ -1321,10 +1321,7 @@
         fmd.setExplicit(true);
         fmd.setManagement(FieldMetaData.MANAGE_PERSISTENT);
 
-        String val = attrs.getValue("fetch");
-        if (val != null)
-            fmd.setInDefaultFetchGroup("EAGER".equals(val));
-        val = attrs.getValue("optional");
+        String val = attrs.getValue("optional");
         if ("false".equals(val))
             fmd.setNullValue(FieldMetaData.NULL_EXCEPTION);
         else if ("true".equals(val)
@@ -1373,6 +1370,10 @@
                 parseOneToMany(fmd, attrs);
                 break;
             case TRANSIENT:
+                String val = attrs.getValue("fetch");
+                if (val != null) {
+                    fmd.setInDefaultFetchGroup("EAGER".equals(val));
+                }
                 fmd.setManagement(FieldMetaData.MANAGE_NONE);
                 break;
             case ELEM_COLL:
@@ -1385,6 +1386,10 @@
      */
     protected void parseBasic(FieldMetaData fmd, Attributes attrs)
         throws SAXException {
+        String val = attrs.getValue("fetch");
+        if (val != null) {
+            fmd.setInDefaultFetchGroup("EAGER".equals(val));
+        }
     }
 
     /**
@@ -1393,6 +1398,7 @@
     protected void parseEmbedded(FieldMetaData fmd, Attributes attrs)
         throws SAXException {
         assertPC(fmd, "Embedded");
+        fmd.setInDefaultFetchGroup(true);
         fmd.setEmbedded(true);
         fmd.setSerialized(false); // override any Lob annotation
         
@@ -1416,13 +1422,15 @@
      */
     protected void parseOneToOne(FieldMetaData fmd, Attributes attrs)
         throws SAXException {
-        String val = attrs.getValue("target-entity");
+        String val = attrs.getValue("fetch");
+        if (val != null && "EAGER".equals(val)) {
+            fmd.setInDefaultFetchGroup(true);
+        }
+        val = attrs.getValue("target-entity");
         if (val != null)
             fmd.setTypeOverride(classForName(val));
         assertPC(fmd, "OneToOne");
         fmd.setSerialized(false); // override any Lob annotation
-        if (!fmd.isDefaultFetchGroupExplicit())
-            fmd.setInDefaultFetchGroup(true);
         boolean orphanRemoval = Boolean.valueOf(attrs.getValue(
             "orphan-removal"));
         setOrphanRemoval(fmd, orphanRemoval);
@@ -1433,13 +1441,15 @@
      */
     protected void parseManyToOne(FieldMetaData fmd, Attributes attrs)
         throws SAXException {
-        String val = attrs.getValue("target-entity");
+        String val = attrs.getValue("fetch");
+        if (val != null && "EAGER".equals(val)) {
+            fmd.setInDefaultFetchGroup(true);
+        }
+        val = attrs.getValue("target-entity");
         if (val != null)
             fmd.setTypeOverride(classForName(val));
         assertPC(fmd, "ManyToOne");
         fmd.setSerialized(false); // override any Lob annotation
-        if (!fmd.isDefaultFetchGroupExplicit())
-            fmd.setInDefaultFetchGroup(true);
     }
 
     /**
@@ -1447,7 +1457,11 @@
      */
     protected void parseManyToMany(FieldMetaData fmd, Attributes attrs)
         throws SAXException {
-        String val = attrs.getValue("target-entity");
+        String val = attrs.getValue("fetch");
+        if (val != null) {
+            fmd.setInDefaultFetchGroup("EAGER".equals(val));
+        }
+        val = attrs.getValue("target-entity");
         if (val != null)
             fmd.getElement().setDeclaredType(classForName(val));
         assertPCCollection(fmd, "ManyToMany");
@@ -1477,7 +1491,11 @@
      */
     protected void parseOneToMany(FieldMetaData fmd, Attributes attrs)
         throws SAXException {
-        String val = attrs.getValue("target-entity");
+        String val = attrs.getValue("fetch");
+        if (val != null) {
+            fmd.setInDefaultFetchGroup("EAGER".equals(val));
+        }
+        val = attrs.getValue("target-entity");
         if (val != null)
             fmd.getElement().setDeclaredType(classForName(val));
         assertPCCollection(fmd, "OneToMany");



Mime
View raw message