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

Comments

Projects
None yet
2 participants
@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

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Apr 5, 2014

Member

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.

Member

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

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Apr 7, 2014

Member

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

Member

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

This comment has been minimized.

Show comment
Hide comment
@yrodiere

yrodiere Apr 9, 2014

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

yrodiere commented Apr 9, 2014

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

@yrodiere

This comment has been minimized.

Show comment
Hide comment
@yrodiere

yrodiere Apr 10, 2014

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

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

@timowest timowest closed this in #700 Apr 10, 2014

@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

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest May 2, 2014

Member

Released in 3.3.3

Member

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