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

Qute does not invoke getters generated by Hibernate Panache #14918

Closed
gastaldi opened this issue Feb 8, 2021 · 3 comments · Fixed by #14937
Closed

Qute does not invoke getters generated by Hibernate Panache #14918

gastaldi opened this issue Feb 8, 2021 · 3 comments · Fixed by #14937
Labels
area/hibernate-orm Hibernate ORM area/panache area/persistence OBSOLETE, DO NOT USE area/qute The template engine kind/bug Something isn't working
Milestone

Comments

@gastaldi
Copy link
Contributor

gastaldi commented Feb 8, 2021

Describe the bug
Because Qute accesses properties using the public field access, lazy loading is never triggered when Qute templates are rendered.

Expected behavior
When iterating a lazy (default) @OneToMany relationship, the entities should be queried from the DB (implemented in Panache when the getter method is invoked).

Actual behavior
Lazy collections in @OneToMany associations are never triggered

To Reproduce
Run the following project:

code-with-quarkus.zip

And hit http://localhost:8080/fruits. You should see Apple.

Go to the Fruit entity an uncomment the getter + private field and hit the URL again. You'll see Apple and two worms

@gastaldi gastaldi added the kind/bug Something isn't working label Feb 8, 2021
@ghost ghost added area/hibernate-orm Hibernate ORM area/panache area/persistence OBSOLETE, DO NOT USE area/qute The template engine labels Feb 8, 2021
@ghost
Copy link

ghost commented Feb 8, 2021

@mkouba
Copy link
Contributor

mkouba commented Feb 9, 2021

OK, so Panache generates a getter that looks like:

@JsonProperty
public List<Bug> getBugs() {
   return this.$$_hibernate_read_bugs();
}

public List $$_hibernate_read_bugs() {
   if (this.$$_hibernate_getInterceptor() != null) {
      this.bugs = (List) this.$$_hibernate_getInterceptor().readObject(this, "bugs", this.bugs);
   }
   return this.bugs;
}

However, Qute does not read the modified bytecode but the Jandex index that obviously does not reflect this transformation.

I think that the easiest (not the most correct) solution would be to always pretend there is a getter if a class extends PanacheEntity. It should be really straightforward. I can try to prepare a PR so that we can evaluate this solution.

@mkouba
Copy link
Contributor

mkouba commented Feb 9, 2021

Here it is: #14937

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hibernate-orm Hibernate ORM area/panache area/persistence OBSOLETE, DO NOT USE area/qute The template engine kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants