openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Sutter" <kwsut...@gmail.com>
Subject Re: svn commit: r566006 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java openjpa-kernel/src/main/java/org/apache/openjpa/util/OpenJPAId.java
Date Wed, 15 Aug 2007 13:59:05 GMT
This one works much better!  Thank you!

Kevin

On 8/14/07, wisneskid@apache.org <wisneskid@apache.org> wrote:
>
> Author: wisneskid
> Date: Tue Aug 14 19:24:50 2007
> New Revision: 566006
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=566006
> Log:
> Help Catalina committing OPENJPA-313.2.patch
>
> Modified:
>
>     openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java
>
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/OpenJPAId.java
>
> Modified:
> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java
> URL:
> http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java?view=diff&rev=566006&r1=566005&r2=566006
>
> ==============================================================================
> ---
> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java
> (original)
> +++
> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java
> Tue Aug 14 19:24:50 2007
> @@ -30,6 +30,7 @@
> import java.util.Map;
> import java.util.Set;
>
> +import org.apache.commons.lang.StringUtils;
> import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
> import org.apache.openjpa.jdbc.kernel.JDBCStore;
> import org.apache.openjpa.jdbc.meta.strats.NoneClassStrategy;
> @@ -189,8 +190,34 @@
>              }
>          }
>          Object oid = ApplicationIds.fromPKValues(vals, cls);
> -        if (!subs && oid instanceof OpenJPAId)
> -            ((OpenJPAId) oid).setManagedInstanceType(cls.getDescribedType
> ());
> +
> +        /**
> +         * For polymorphic relations,
> +         * the type field in the oid is initially set to base type.
> +         * If the discriminator value is preset in the current result,
> +         * then the type field needs reset based on the discriminator
> value.
> +         * If the discriminator value is not present or invalid,
> +         * ignore any exceptions being thrown.
> +         */
> +        if (oid instanceof OpenJPAId) {
> +            Class type = cls.getDescribedType();
> +            if (!subs)
> +                // non-polymorphic relations
> +                ((OpenJPAId) oid).setManagedInstanceType(type);
> +            else if (cls.getDiscriminator() != null
> +                && !StringUtils.equals("none",
> +                    cls.getDiscriminator().getStrategy().getAlias())) {
> +                // polymorphic relations
> +                res.startDataRequest(cls.getDiscriminator());
> +                try {
> +                    type = cls.getDiscriminator().getClass(store, cls,
> res);
> +                    ((OpenJPAId) oid).setManagedInstanceType(type, true);
> +                } catch (Exception e) {
> +                    // intentionally ignored
> +                }
> +                res.endDataRequest();
> +            }
> +        }
>          return oid;
>      }
>
>
> Modified:
> openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/OpenJPAId.java
> URL:
> http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/OpenJPAId.java?view=diff&rev=566006&r1=566005&r2=566006
>
> ==============================================================================
> ---
> openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/OpenJPAId.java
> (original)
> +++
> openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/OpenJPAId.java
> Tue Aug 14 19:24:50 2007
> @@ -78,6 +78,14 @@
>      }
>
>      /**
> +     * Set the exact type of the described instance once it is known.
> +     */
> +    public void setManagedInstanceType(Class type, boolean subs) {
> +        this.type = type;
> +        this.subs = subs;
> +    }
> +
> +    /**
>       * Return the identity value as an object.
>       */
>      public abstract Object getIdObject();
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message