You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "jieryn (JIRA)" <ji...@apache.org> on 2012/05/09 15:15:51 UTC

[jira] [Commented] (OPENJPA-2188) metamodel generation with internal Map creates invalid metamodel

    [ https://issues.apache.org/jira/browse/OPENJPA-2188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13271397#comment-13271397 ] 

jieryn commented on OPENJPA-2188:
---------------------------------

Even when I change BuggyMetamodel.java to:

{code}  protected static Path<SortedMap> pathMap1(final Root<BuggyMetamodel> root)
  {
    return root.<SortedMap>get(BuggyMetamodel_.map1);
  }

  protected static Path<SortedMap> pathMap2(final Root<BuggyMetamodel> root)
  {
    return root.<SortedMap<Type, SortedMap>>get(BuggyMetamodel_.map2);
  }
{code}

I still take compilation errors. So I don't think this is a generics issue, at least in an obvious way..
                
> metamodel generation with internal Map creates invalid metamodel
> ----------------------------------------------------------------
>
>                 Key: OPENJPA-2188
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2188
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.2.0
>            Reporter: jieryn
>
> {code}import java.util.SortedMap;
> import java.util.TreeMap;
> import javax.persistence.Basic;
> import javax.persistence.ElementCollection;
> import javax.persistence.Entity;
> import javax.persistence.criteria.Path;
> import javax.persistence.criteria.Root;
> @Entity
> public final class BuggyMetamodel
> {
>   enum Type
>   {
>     A,
>     B,
>     C;
>   }
>   protected static Path<SortedMap<Type, Integer>> pathMap1(
>       final Root<BuggyMetamodel> root)
>   {
>     return root.<SortedMap<Type, Integer>>get(BuggyMetamodel_.map1);
>   }
>   protected static Path<SortedMap<Type, Integer>> pathMap2(
>       final Root<BuggyMetamodel> root)
>   {
>     return root
>         .<SortedMap<Type, SortedMap<String, Integer>>>get(BuggyMetamodel_.map2);
>   }
>   protected static Path<String> pathString(final Root<BuggyMetamodel> root)
>   {
>     return root.<String>get(BuggyMetamodel_.string);
>   }
>   @ElementCollection
>   private final SortedMap<Type, Integer>                    map1   = new TreeMap<Type, Integer>();
>   @ElementCollection
>   private final SortedMap<Type, SortedMap<String, Integer>> map2   = new TreeMap<Type, SortedMap<String, Integer>>();
>   @Basic
>   private final String                                      string = "OpenJPA Rocks!";
> }
> {code}
> nearly produces (minor change to remove "package ;" -- see OPENJPA-2187)
> {code}/** 
>  *  Generated by OpenJPA MetaModel Generator Tool.
>  **/
> import java.util.SortedMap;
> import javax.persistence.metamodel.MapAttribute;
> import javax.persistence.metamodel.SingularAttribute;
> @javax.persistence.metamodel.StaticMetamodel(value = BuggyMetamodel.class)
> @javax.annotation.Generated(value = "org.apache.openjpa.persistence.meta.AnnotationProcessor6", date = "Wed May 09 08:58:50 EDT 2012")
> public class BuggyMetamodel_
> {
>   public static volatile MapAttribute<BuggyMetamodel, BuggyMetamodel.Type, Integer>   map1;
>   public static volatile MapAttribute<BuggyMetamodel, BuggyMetamodel.Type, SortedMap> map2;
>   public static volatile SingularAttribute<BuggyMetamodel, String>                    string;
> }
> {code}
> which will not let BuggyMetamodel compile because:
> {code}[INFO] -------------------------------------------------------------
> [ERROR] COMPILATION ERROR : 
> [INFO] -------------------------------------------------------------
> [ERROR] /workspace/project/src/main/java/BuggyMetamodel.java:[23,15] cannot find symbol
> symbol  : method <java.util.SortedMap<BuggyMetamodel.Type,java.lang.Integer>>get(javax.persistence.metamodel.MapAttribute<BuggyMetamodel,BuggyMetamodel.Type,java.lang.Integer>)
> location: interface javax.persistence.criteria.Root<BuggyMetamodel>
> [ERROR] /workspace/project/src/main/java/BuggyMetamodel.java:[30,8] cannot find symbol
> symbol  : method <java.util.SortedMap<BuggyMetamodel.Type,java.util.SortedMap<java.lang.String,java.lang.Integer>>>get(javax.persistence.metamodel.MapAttribute<BuggyMetamodel,BuggyMetamodel.Type,java.util.SortedMap>)
> location: interface javax.persistence.criteria.Root<BuggyMetamodel>
> [INFO] 2 errors 
> [INFO] -------------------------------------------------------------
> {code}
> There's some fairly unreadable generic code going on, and I am not sure whether the reduction of SortedMap<String,Integer> to SortedMap without generic types is not a separate bug .... but either way, the metamodel generated classes are not usable in this configuration.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira