Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in JavaTypeMapping.findType #417

Open
bhnedo opened this issue May 15, 2013 · 5 comments
Open

NullPointerException in JavaTypeMapping.findType #417

bhnedo opened this issue May 15, 2013 · 5 comments
Labels

Comments

@bhnedo
Copy link

@bhnedo bhnedo commented May 15, 2013

Hi,

I have the following QueryDSL query:

Map<String, RiskAnalysis> r = query.from(analysis)
.innerJoin(user).on(analysis.creatorId.eq(user.id))
.innerJoin(qe).on(analysis.id.eq(qe.itemId))
.innerJoin(enterprise).on(enterprise.id.eq(qe.enterpriseId))
.innerJoin(methodology).on(methodology.id.eq(analysis.methodologyId))
.innerJoin(status).on(status.id.eq(analysis.statusId))

                                  .leftJoin(assetThreat).on(assetThreat.riskAnalysisId.eq(riskAnalysisId))
                                  .leftJoin(threat).on(threat.id.eq(assetThreat.threatId))
                                  .leftJoin(asset).on(asset.id.eq(assetThreat.assetId))

                                  .leftJoin(lock).on(analysis.id.eq(lock.elementId))
                                  .where( analysis.id.eq(riskAnalysisId),
                                          analysis.deletionDate.isNull()
                                         .and( qe.enterpriseId
                                         .in(currentlyAssignedUserEnterprises(userId))))
                                  .transform(groupBy(analysis.id).as(Projections.constructor(RiskAnalysis.class, 
                                                              analysis.id,
                                                              analysis.name,
                                                              analysis.description,
                                                              analysis.version,
                                                              enterprise.name,
                                                              enterprise.id,
                                                              analysis.startDate,
                                                              analysis.endDate,
                                                              user(),
                                                              analysis.notes,
                                                              analysis.statusId,
                                                              status.name,
                                                              analysis.methodologyId,
                                                              methodology.description,
                                                              lock(),
                                                              set(Projections.constructor(
                                                                      AssetThreat.class, 
                                                                      assetThreat.id,
                                                                      assetThreat.assetId,
                                                                      assetThreat.riskAnalysisId,
                                                                      asset.name,
                                                                      set(Projections.bean(Threat.class, threat.id))
                                                              )))));

When second inner Set is used (if I remove it, everything works OK), the following exception is thrown:

java.lang.NullPointerException
at com.mysema.query.sql.JavaTypeMapping.findType(JavaTypeMapping.java:142)
at com.mysema.query.sql.JavaTypeMapping.getType(JavaTypeMapping.java:119)
at com.mysema.query.sql.Configuration.getType(Configuration.java:125)
at com.mysema.query.sql.Configuration.get(Configuration.java:95)
at com.mysema.query.sql.AbstractSQLQuery.get(AbstractSQLQuery.java:287)
at com.mysema.query.sql.AbstractSQLQuery.newInstance(AbstractSQLQuery.java:494)
at com.mysema.query.sql.AbstractSQLQuery.access$000(AbstractSQLQuery.java:62)
at com.mysema.query.sql.AbstractSQLQuery$2.produceNext(AbstractSQLQuery.java:372)
at com.mysema.query.sql.AbstractSQLQuery$2.produceNext(AbstractSQLQuery.java:361)
at com.mysema.query.sql.SQLResultIterator.next(SQLResultIterator.java:81)
at com.mysema.query.group.GroupBy.transform(GroupBy.java:156)
at com.mysema.query.group.GroupBy.transform(GroupBy.java:34)

AssetThreat bean has a set of Threat objects:

public class AssetThreat {

private String assetId;

private String formula;

private String id;

private String riskAnalysisId;


private Double value;

private String assetName;

private Set<Threat> threats;

}

and RiskAnalysis contains a collection of AssetThreat:

public class RiskAnalysis {

private String actorId;

private String creatorId;

private String description;

private java.sql.Timestamp endDate;

private String id;

private Short methodologyId;

private String methodologyDescription;

private String name;

private String notes;

private Short riskLevel;

private java.sql.Timestamp startDate;

private Short statusId;

private String statusName;

private String version;

private String enterpriseName;

private String enterpriseId;

private String creatorName;

private Lock lock;

private Set<AssetThreat> assetThreats;

}

timowest added a commit that referenced this issue May 15, 2013
timowest added a commit that referenced this issue May 16, 2013
@ghost ghost assigned timowest Jul 31, 2013
@timowest
Copy link
Member

@timowest timowest commented Aug 5, 2013

Could you try your case with the latest SNAPSHOT from here https://oss.sonatype.org/content/repositories/snapshots/ ?

@timowest
Copy link
Member

@timowest timowest commented Aug 27, 2013

Released in 3.2.3

@timowest timowest closed this Aug 27, 2013
@bhnedo
Copy link
Author

@bhnedo bhnedo commented Oct 8, 2013

Can you please reopen this issue? My test case is failing with another exception:

java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysema.query.types.ConstructorExpression.newInstance(ConstructorExpression.java:162)
at com.mysema.query.types.FactoryExpressionUtils.compress(FactoryExpressionUtils.java:141)
at com.mysema.query.types.FactoryExpressionUtils.access$100(FactoryExpressionUtils.java:28)
at com.mysema.query.types.FactoryExpressionUtils$FactoryExpressionAdapter.newInstance(FactoryExpressionUtils.java:51)
at com.mysema.query.group.GroupBy$FactoryExpressionAdapter.newInstance(GroupBy.java:68)
at com.mysema.query.types.FactoryExpressionUtils$FactoryExpressionAdapter.newInstance(FactoryExpressionUtils.java:51)
at com.mysema.query.sql.AbstractSQLQuery.newInstance(AbstractSQLQuery.java:565)
at com.mysema.query.sql.AbstractSQLQuery.access$000(AbstractSQLQuery.java:67)
at com.mysema.query.sql.AbstractSQLQuery$3.produceNext(AbstractSQLQuery.java:444)
at com.mysema.query.sql.SQLResultIterator.next(SQLResultIterator.java:82)
at com.mysema.query.group.GroupBy.transform(GroupBy.java:203)
at com.mysema.query.group.GroupBy.transform(GroupBy.java:42)
at com.mysema.query.support.ProjectableQuery.transform(ProjectableQuery.java:80)

@timowest timowest reopened this Oct 8, 2013
@bhnedo
Copy link
Author

@bhnedo bhnedo commented Jan 3, 2014

Hi Timo. Any plans to solve this bug soon?

@timowest
Copy link
Member

@timowest timowest commented Jan 4, 2014

Sorry for the delay, I will look into this soon.

@timowest timowest modified the milestone: 3.2.3 Apr 13, 2014
@timowest timowest removed this from the 3.2.3 milestone Nov 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants