@Basic(fetch=LAZY) has no
effect on the runtime behavior of Hibernate. All fields of an entity
are loaded at the same time, as if they all belonged to the same fetch
group.
@Basic(fetch=LAZY)} is loaded lazily when it is first accessed,
using a separate SQL select statement. Since this trip to the
database is generally expensive, Hibernate will, by default, load all
lazy fields at once. This annotation provides control over that
behavior.
A fetch group identifies a set of related attributes that should be loaded
together when any one of them is accessed. By default, all non-collection
attributes belong to a single fetch group named "DEFAULT". The
fetch group for a given lazy attribute may be explicitly specified using
the value() member of this annotation.
For example, a field annotated @Basic(fetch=LAZY) @LazyGroup("extra")
belongs to the fetch group named "extra", and is loaded whenever an
attribute belonging to the "extra" fetch group is accessed.
Note that field-level lazy fetching is usually of dubious value, and most projects using Hibernate don't even bother enabling the bytecode enhancer.
Cache#includeLazy()
| Modifier and Type | Method and Description |
|---|---|
| public String |
| value | back to summary |
|---|---|
| public String value() | |