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

creating QBean projection with identical Path names #1214

Closed
fe2s opened this issue Feb 19, 2015 · 6 comments
Closed

creating QBean projection with identical Path names #1214

fe2s opened this issue Feb 19, 2015 · 6 comments

Comments

@fe2s
Copy link

fe2s commented Feb 19, 2015

I have two Pathes with identical property names (team.name and team.leader.name)

Projections.bean(QTeam.team, team.name, team.leader.name);

fails with

java.lang.IllegalArgumentException: Multiple entries with same key: name=team.leader.name and name=team.name
    at com.google.common.collect.ImmutableMap.checkNoConflict(ImmutableMap.java:150)
    at com.google.common.collect.RegularImmutableMap.checkNoConflictInBucket(RegularImmutableMap.java:104)
    at com.google.common.collect.RegularImmutableMap.<init>(RegularImmutableMap.java:70)
    at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:254)
    at com.mysema.query.types.QBean.createBindings(QBean.java:72)
    at com.mysema.query.types.QBean.<init>(QBean.java:161)
    at com.mysema.query.types.QBean.<init>(QBean.java:95)
    at com.mysema.query.types.Projections.bean(Projections.java:63)
@timowest
Copy link
Member

How do you want these to be applied to the bean?

@fe2s
Copy link
Author

fe2s commented Feb 19, 2015

I want only name of team and name of team leader, all other properties should be null. Isn't that natural?

@timowest
Copy link
Member

QBean requires unique propert keys and doesn't support implicit intermediate property creation.

@fe2s
Copy link
Author

fe2s commented Feb 19, 2015

Does that mean by design I cannot use for instance MongoDB's projection for nested property and project MongoDB's document to java bean?

@timowest
Copy link
Member

You can populate nested beans, but you will need to do so explicitly.

e.g.

Projections.bean(Team.class, team.name, 
  Projections.bean(Leader.class, team.leader.name).as("leader"))

Assuming that Leader is the type of the intermediate object.

@fe2s
Copy link
Author

fe2s commented Feb 19, 2015

OK, got it. Thanks. Would be nice to support more concise syntax.
Please consider moving this to enhancement or closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants