Hibernate JPA @Proxy Example

@Proxy

The @Proxy annotation is used to specify a custom proxy implementation for the currently annotated entity. Lazy and proxy configuration of a particular class.

Example :

public interface Identifiable {

Long getId();

void setId(Long id);
}

@Entity( name = "Book" )
@Proxy(proxyClass = Identifiable.class)
public static final class Book implements Identifiable {

@Id
private Long id;

private String title;

private String author;

@Override
public Long getId() {
return id;
}

@Override
public void setId(Long id) {
this.id = id;
}

//Other getters and setters omitted for brevity
}
The @Proxy annotation is used to specify a custom proxy implementation for the current annotated entity.

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation