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

Missing .filterMany() conditions for fetched associations on query beans after 15.6.0 #3536

Open
davidhiendl opened this issue Jan 3, 2025 · 5 comments

Comments

@davidhiendl
Copy link

davidhiendl commented Jan 3, 2025

Expected behavior

After upgrading to >= 15.6.0 only ManyToMany/OneToMany are supposed to have .filterMany() conditions for filtering associated beans.

Actual behavior

After upgrading to >= 15.6.0 all relationships lost .filterMany() conditions on query beans for filtering which associated beans that are fetched, regardless of the relationship type.
Reverting to < 15.6.0 restores them without issue.

Steps to reproduce

EDIT: Repository which can be used to reproduce the problem: https://github.com/davidhiendl/ebean-issue-3536

Some example entities + query for sanity check (maybe I misunderstood something?)

Entities:

@Entity
@Table(name = "auth_user")
class AuthUser : TemporalAwareDomainModel() {

    @ManyToMany(mappedBy = "users")
    var tenants: MutableList<AuthTenant> = mutableListOf()

}
@Entity
@Table(name = "auth_tenant")
class AuthTenant : TemporalAwareDomainModel() {

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(
        name = "auth_tenant_user",
        joinColumns = [JoinColumn(name = "tenant_id", referencedColumnName = "id")],
        inverseJoinColumns = [JoinColumn(name = "user_id", referencedColumnName = "id")]
    )
    var users = mutableListOf<AuthUser>()

}

Example query:

val user = QAuthUser(db)
    .id.eq(ctx.userId)
    .tenants.filterMany(QAuthTenant(db).id.eq(params.tenantId).expressionList)
    .findOne()

Generated query beans

When investigating the generated query beans the tenant relation generated as:
QAuthUser -> lateinit var tenants: QAssocAuthTenant<QAuthUser>
and QAssocAuthTenant<R> : TQAssocBean<de.dhswt.bsmxcd.schemasql.core.auth.AuthTenant,R,QAuthTenant>
Which I believe is incorrect and should have generated as inheriting and implementing methods from TQAssocMany

@rbygrave
Copy link
Member

rbygrave commented Jan 6, 2025

What is your annotation processing setup? Are you using kotlin-querybean-generator or querybean-generator etc

@davidhiendl
Copy link
Author

It's kapt "io.ebean:kotlin-querybean-generator:$ebeanVersion"

I already started stripping down the project to create a reproducer, almost ready to upload. Still taking out as much as possible to make sure the issue is not caused by some unintended interference.

@davidhiendl
Copy link
Author

davidhiendl commented Jan 6, 2025

I'd like to point out that #3473 touched the regular querybean-generator but not the kotlin-querybean-generator code.

And yes, using querybean-generator over kotlin-querybean-generator generates the filterMany methods.

@davidhiendl
Copy link
Author

Repository which can be used to reproduce the problem, but I think all that is needed to reproduce the problem is to use kotlin-querybean-generator: https://github.com/davidhiendl/ebean-issue-3536

@rbygrave
Copy link
Member

rbygrave commented Jan 6, 2025

Awesome, thanks !!!

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