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

@QueryProjection generates methods with QSomething arguments, instead of Expression<Something> #697

Closed
yrodiere opened this issue Apr 3, 2014 · 5 comments
Milestone

Comments

@yrodiere
Copy link

@yrodiere yrodiere commented Apr 3, 2014

When using @QueryProjection on a constructor this way:

@Entity
public class MyEntity {
 @ManyToOne
 private Something something;

 @QueryProjection
 public MyEntity(Something something) {
  this.something = something;
 }

 // ...
}

Then the corresponding generated create() method looks like this:

 public class QMyEntity extends EntityPathBase<MyEntity> {
    public static ConstructorExpression<MyEntity> create(QSomething something) {
        return new ConstructorExpression<MyEntity>(MyEntity.class, new Class[]{Something.class}, something);
    }
 // ...
 }

This prevents from passing an Expression<Something> as a parameter wherever we want to use QMyEntity#create. Which is strange, since it uses a ConstructorExpression internally, and ConstructorExpression seems to accept any Expression<?> as a parameter...

Could you please consider using more flexible parameter types when generating the QMyEntity#create method? This may be useful in some cases, for instance when using the when().then() construct (CASE ... WHEN .. THEN ... END in SQL) to build an argument to create().

Thanks a lot.

@timowest
Copy link
Member

@timowest timowest commented Apr 5, 2014

This was chosen to have better separation when creating the constructors, but I see the problem.

If we have two annotated constructors, with both one entity typed argument, we end up some with Expression<Something> and Expression<SomethingElse> which is invalid, since the erasure is the same.

@timowest
Copy link
Member

@timowest timowest commented Apr 7, 2014

@fenrhil Could you try the SNAPSHOT with the version 3.3.3.i697-SNAPSHOT from here https://oss.sonatype.org/content/repositories/snapshots/

@yrodiere
Copy link
Author

@yrodiere yrodiere commented Apr 9, 2014

@timowest Thanks, I'll give it a try very soon, probably tomorow.

@yrodiere
Copy link
Author

@yrodiere yrodiere commented Apr 10, 2014

@timowest It works just fine. Thank you for your responsiveness!

@timowest timowest reopened this Apr 10, 2014
@timowest timowest added the fixed label Apr 10, 2014
@timowest timowest modified the milestone: 3.3.3 Apr 13, 2014
@timowest timowest modified the milestone: 3.3.3 Apr 30, 2014
@timowest
Copy link
Member

@timowest timowest commented May 2, 2014

Released in 3.3.3

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

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.