Skip to content

Assoc QueryBeans are broken after upgrading to 15.6.0 #3484

@tobias-

Description

@tobias-

TL;DR NoSuchMethodError when using basic functionality of QueryBeans.

Skipping a lot of needed boiler plate to focus on the problem.

@Entity
public class Foo {
    public Bar bar;
}

@Entity
public class Bar {
    public String id;
}

new QFoo(database)
  .bar.id.eq("foo")

The beans will not get the necessary constructors added when building this with :

  • Gradle plugin 15.6.0
  • ebean-agent 15.6.0
  • ebean-api/ebean-core 15.6.0)

Decompiled version of the generated+transformed Foo._bar() method:

  public query.assoc.QAssocBar<query.QFoo> _bar();
    Code:
       0: aload_0
       1: getfield      #114                // Field query/assoc/QAssocBar;
       4: ifnonnull     22
       7: aload_0
       8: new           #111                // class query/assoc/QAssocBar
      11: dup
      12: ldc           #105                // String email
      14: aload_0
      15: iconst_1
      16: invokespecial #211                // Method query/assoc/QAssocBar."<init>":(Ljava/lang/String;Ljava/lang/Object;I)V
      19: putfield      #114                // Field email:Lquery/assoc/QAssocBar;
      22: aload_0
      23: getfield      #114                // Field email:Lquery/assoc/QAssocBar;
      26: areturn

The only constructors in the class Bar after transformation are:

  public query.assoc.QAssocBar(java.lang.String, R, java.lang.String);
  public query.assoc.QAssocBar(java.lang.String, R);

After investigation, it seems the (partial) is the improvedQueryBeans concept used in TypeQueryClassAdapter that was added in September. If the ebean-version is >= 145 (which it is in ebean-api), query beans are defined as "improved". This means that the beans are not transformed to get the extra constructors.

In FieldInfo.writeMethod there is no concept of improved, thus the constructor called is QAssocBar(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/String;I)V

Expected behavior

Being able to use query bean associated beans.

Actual behavior

java.lang.NoSuchMethodError: 'void query.assoc.QAssocBar.<init>(java.lang.String, java.lang.Object, int)'

--edit I forgot to add that the query beans I generate are in Kotlin, but the code seems to take the same paths, only the generation of the QueryBeans are different.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions