Hibernate JPA @LazyGroup Example

@LazyGroup

The @LazyGroup annotation is used to specify that an entity attribute should be fetched along with all the other attributes belonging to the same group.

To load entity attributes lazily, bytecode enhancement is needed. By default, all non-collection attributes are loaded in one group named "DEFAULT".

This annotation allows defining different groups of attributes to be initialized together when access one attribute in the group.

LazyGroup

For use with bytecode-enhanced lazy-loading support.
Identifies grouping for performing lazy attribute loading. By default all non-collection attributes are loaded in one group named "DEFAULT". This annotation allows defining different groups of attributes to be initialized together when access one attribute in the group.

@LazyGroup example

@Entity
public class Customer {

@Id
private Integer id;

private String name;

@Basic( fetch = FetchType.LAZY )
private UUID accountsPayableXrefId;

@Lob
@Basic( fetch = FetchType.LAZY )
@LazyGroup( "lobs" )
private Blob image;

//Getters and setters are omitted for brevity

}

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation