Eager Fetch Type On Association (ARCH4060)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Key java.orm.eager-fetch-type-on-association · Severity warning · Category orm
Declaring an association fetch = EAGER at the mapping level fetches it needlessly on every query of the owning entity. Leave it LAZY by default and eager-load per query when needed.
Incorrect
Section titled “Incorrect”@Entitypublic class Order { @OneToMany(fetch = FetchType.EAGER) // items fetched on every Order query private List<LineItem> items;}Correct
Section titled “Correct”@Entitypublic class Order { @OneToMany(fetch = FetchType.LAZY) private List<LineItem> items;}// when needed: SELECT o FROM Order o JOIN FETCH o.itemsDeclare associations LAZY and selectively eager-load with JOIN FETCH in the queries that need them.