Comment 2 for bug 856099

Revision history for this message
Thomas Adams (heinrich-adams) wrote : RE: [Bug 856099] Re: Map entity property throws a NPE

Hi,

Trying to create a simple example from the bottom up, however
I could not reproduce that either. However, removing all properties of the
entities and adding them step by step up again, I'm now getting
trouble to generate the sources again (same stacktrace as before)

@Entity(value = "PERSON", noClassnameStored = true)
public class Person implements
  org.apache.shindig.social.opensocial.model.Person {

 private static final long serialVersionUID = 1L;

 @Id
 private ObjectId objectId = null;

 private String id;
 ....

      // the next two methods are causing the trouble
 @Override
 public Map<String, ?> getAppData() {
  return personAppData;
 }

 @Override
 public void setAppData(Map<String, ?> appData) {
  Map<String, String> m = new HashMap<String, String>();
  for (Iterator<String> iterator =
appData.keySet().iterator(); iterator
    .hasNext();) {

   String k = iterator.next();
   String v = (String) appData.get(k);

   m.put(k, v);

  }
  personAppData = m;
 }

Once these 2 methods are removed at least the source generation runs
through, however there is now
A Qstring class generated with compiler errors:

public class QString extends BeanPath {

...

    public QString(BeanPath<String> entity) {
        super(entity.getMetadata());
    }

    public QString(PathMetadata<?> metadata) {
        super(metadata);
    }

...

}

The compiler complains about : The constructor
BeanPath(PathMetadata<capture#2-of ?>) is undefined.

This is really out of my expertise now, so far what
I got when using querydsl with JPA in that case was
a StringPath.

C. Thomas

-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Timo
Westkämper
Sent: 26 September 2011 15:50
To: <email address hidden>
Subject: [Bug 856099] Re: Map entity property throws a NPE

Could you provide a minimal example project where this fails? I have not yet
been able to reproduce this issue.

** Changed in: querydsl
       Status: New => In Progress

** Changed in: querydsl
   Importance: Undecided => High

--
You received this bug notification because you are subscribed to the bug
report.
https://bugs.launchpad.net/bugs/856099

Title:
  Map entity property throws a NPE

Status in Querydsl:
  In Progress

Bug description:
  I have the following entity classes, beside a couple of other (so far
  non critical).

  @Entity(value = "USER", noClassnameStored = true)
  public class User implements IUser, UserDetails, Account {
          ....
          @Embedded
          private Map<String, UserAttribute> properties;
          ....
          //usual getter an setters

  }

  @Embedded
  public class UserAttribute implements IAttribute {

          //simple property values (String, Object or Date)
  }

  When i generate the sources with mvn i run into:

  An annotation processor threw an uncaught exception.
  Consult the following stack trace for details.
  java.lang.NullPointerException
  at
com.mysema.query.apt.ExtendedTypeFactory.createMapType(ExtendedTypeFactory.j
ava:234)
  at
com.mysema.query.apt.ExtendedTypeFactory.createInterfaceType(ExtendedTypeFac
tory.java:366)
  at
com.mysema.query.apt.ExtendedTypeFactory.handleDeclaredType(ExtendedTypeFact
ory.java:462)
  at
com.mysema.query.apt.ExtendedTypeFactory.handle(ExtendedTypeFactory.java:441
)
  at
com.mysema.query.apt.ExtendedTypeFactory.createType(ExtendedTypeFactory.java
:158)
  at
com.mysema.query.apt.ExtendedTypeFactory.getType(ExtendedTypeFactory.java:15
1)
  at
com.mysema.query.apt.ElementHandler.handleMethodProperty(ElementHandler.java
:182)
  at
com.mysema.query.apt.ElementHandler.handleEntityType(ElementHandler.java:104
)
  at com.mysema.query.apt.Processor.process(Processor.java:467)
  at com.mysema.query.apt.Processor.processEntities(Processor.java:669)
  at com.mysema.query.apt.Processor.processAnnotations(Processor.java:181)
  at com.mysema.query.apt.Processor.process(Processor.java:127)
  at
com.mysema.query.mongodb.morphia.MorphiaAnnotationProcessor.process(MorphiaA
nnotationProcessor.java:
  54)
  at
com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(Java
cProcessingEnvironment.j
  ava:625)
  at
com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProc
s(JavacProcessingEnviron
  ment.java:554)
  at
com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(Javac
ProcessingEnvironment.ja
  va:699)
  at
com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:9
81)
  at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
  at com.sun.tools.javac.main.Main.compile(Main.java:353)
  at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:115)
  at
com.mysema.maven.apt.AbstractProcessorMojo.execute(AbstractProcessorMojo.jav
a:210)
  at
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPl
uginManager.java:105)
  at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycle
Executor.java:577)
  at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycle
Executor.java:324)
  at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:247)
  at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:104)
  at org.apache.maven.cli.MavenCli.execute(MavenCli.java:427)
  at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:157)
  at org.apache.maven.cli.MavenCli.main(MavenCli.java:121)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
  at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at
org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.ja
va:290)
  at
org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
  at
org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.
java:409)
  at
org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

  Excluding the above user class by removing the entity annotation
  leads to a successful source generation.

  version apt 1.0.2, version dsl 2.2.2

  Any ideas? I tried playing with

  <querydsl.mapAccessors>false</querydsl.mapAccessors>

  and
  <querydsl.mapAccessors>true</querydsl.mapAccessors>

  but this seems to have no effect, even omitting the option completely
  yields the same error result.

To manage notifications about this bug go to:
https://bugs.launchpad.net/querydsl/+bug/856099/+subscriptions