Buradasın
Hibernate Loading Strategies
baeldung.com/hibernate-lazy-eager-loadingYapay zekadan makale özeti
- Types and Basics
- Data fetching in ORMs can be eager or lazy
- Eager loading initializes data on the spot
- Lazy loading defers initialization until explicitly called
- Implementation in Hibernate
- Lazy loading uses proxy objects and separate SQL queries
- Eager loading loads all associated data immediately
- Default fetch type is lazy for @OneToMany and @ManyToMany
- Hibernate recommends static lazy marking for associations
- Advantages and Disadvantages
- Lazy loading saves memory by avoiding unnecessary data fetching
- Eager loading loads all related data upfront
- Disabling proxies is considered bad practice in Hibernate
- JPA specification defines default fetch type for associations
- Configuration
- Loading strategies can be configured using annotations
- Configuration settings are in fetching.hbm.xml
- Proxy objects are created for lazy loading
- Collection classes require wrapper implementation