Test for GetchGroup#3786
Conversation
|
Maybe: Verdict: not an ebean bug — usage error. Reproduced the failure (LazyInitialisationException: Property not loaded: name). Root cause: the new test fetches fetchQuery("attributeValues", "intValue") but then accesses AttributeValue.name (a newly added @manytoone Label) which is never fetched; combined with setUnmodifiable(true) (read-only beans → lazy loading disabled by design), accessing the unfetched property correctly throws. Confirmed fix: changing to fetchQuery("attributeValues", "intValue, name") makes the test pass including assertThat(sql).isEmpty() — the Label graph resolves entirely from the ImmutableBeanCache with zero lazy-load SQL, which is exactly the author's goal. |
There was a problem hiding this comment.
Pull request overview
This PR extends the resource test model and test coverage to reproduce/validate immutable-cache + FetchGroup behavior when loading deeper parts of the object graph (specifically AttributeValue -> Label -> labelTexts) and adds a Spring module load/update scenario.
Changes:
- Add a
name(Label) association toAttributeValue, including constructor/getter/setter updates. - Extend
ResourceEntityTestsetup data and add a new test that accessesAttributeValue.name.labelTextswhile using an immutableLabelcache andsetUnmodifiable(true). - Add a new (currently non-annotated)
testLoad()method inEbeanSpringModuleTest.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| ebean-test/src/test/java/org/tests/resource/ResourceEntityTest.java | Adds AttributeValue label setup, a new immutable-cache/fetchGroup test, and a cache helper that loads labelTexts. |
| ebean-test/src/test/java/org/tests/resource/AttributeValue.java | Introduces Label name ManyToOne association and updates constructors/accessors accordingly. |
| ebean-spring-txn/src/test/java/org/example/EbeanSpringModuleTest.java | Adds a new load/update test scenario for User. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| av1.getName().addLabelText(de, "AV1 DE"); | ||
| av1.getName().addLabelText(en, "AV1 EN"); | ||
| AttributeValue av2 = new AttributeValue(new Label(), 2, widthDescriptor); | ||
| av2.getName().addLabelText(de, "AV2 DE"); | ||
| av2.getName().addLabelText(en, "AV2 EN"); |
| logger.info("nonTransactional find user1:{} user2:{}", user, user2); | ||
| } | ||
|
|
||
| public void testLoad() { |
|
|
||
| found = DB.find(User.class, user.getOid()); | ||
|
|
||
| assertThat(user.getName()).equals(found.getName()); |
|
I changed the code in the test case as follows (line 678) but still getting |
|
Agent says: └ Re-reviewed PR #3786. Key new finding: the contributor (nedge) misapplied my suggested fix. They added , name to the find_fetchLazySecondary_… test (line 678 — which wasn't failing and doesn't use setUnmodifiable), but the actually-failing test a_find_fetchQuerySecondary_… (~line 646) is unchanged and still has fetchQuery("attributeValues", "intValue") with setUnmodifiable(true) — hence the same LazyInitialisationException: Property not loaded: name. |
|
I still have issues in Timerbee with the FetchGroup - One part may have to do with using inheritance so I will try to remove the inheritance first. |
I'm trying to force the loading of OneToMany using FetchGroups in a query....setUnmodifiable(true)
My goal is to be able to load parts of the object graph and use the ImmutableBeanCache functionality but I get
ResourceEntityTest.a_find_fetchQuerySecondary_inheritsImmutableCache_expect_noLabelLazyLoadSql:662->lambda$a_find_fetchQuerySecondary_inheritsImmutableCache_expect_noLabelLazyLoadSql$19:663 » LazyInitialisation Property not loaded: name