Repository navigation
feat: Add NoEagerToOneAssociationRule as a standalone rule - #165
Merged
Merged
Conversation
Flags every field or getter annotated @manytoone or @OnetoOne, Jakarta or javax Persistence, whose fetch is not LAZY or that carries Hibernate's @fetch(FetchMode.JOIN). Closes #61. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Closes #61.
Summary
corral.jakarta.no-eager-to-one-association, a standalone rule (in no group). Consumers wire it withArchTests.in(NoEagerToOneAssociationRule.class).@ManyToOne/@OneToOne, Jakarta orjavaxPersistence, that is either:fetch = LAZY(the spec default for a to-one isEAGER), or@Fetch(FetchMode.JOIN), which loads it eagerly whateverfetchsays.Field <…> is a to-one association that may be fetched eagerly in (File.java:N).fetchisFetchType.DEFAULTand follows the persistence unit's setting.fetchvalue, which differs by API version and classpath.fetchstill counts as eager. It checks production and test classes.orm.xmlmappings;@Any,@LazyToOneand@NotFound;@jakarta.persistence.Fetch(not final yet, so there is no real type to build a fixture from);LAZYto-one that Hibernate loads immediately anyway: the inverse side of an optional@OneToOne, or a target entity it cannot proxy.stored.rulesline, a field onEveryStandaloneRule, and a row in the Standalone table ofdocs/rules.md.Test plan
./mvnw clean verify: green, coverage gates met.javaxentity and a property-access entity, all built from realjakarta.persistence-api,javax.persistence-apiandhibernate-coretypes;LAZY/JOINfilters, the@Fetchname and the handling of an absentfetch. A named test failed for every one.rule-reviewerrun. Its findings are fixed: the wording now holds on JPA 4.0, the 4.0@Fetchgap is documented, the warning about targets that can't be proxied is in How to fix, and the exact-line assertion for the unresolved type is added.🤖 Generated with Claude Code