Hibernate JPA @Tuplizer Example
@Tuplizer
The @Tuplizer annotation is used to specify a custom tuplizer for the currently annotated entity or embeddable.For entities, the tupelizer must implement the EntityTuplizer interface.
For embeddables, the tupelizer must implement the ComponentTuplizer interface.
Dynamic entity proxies using the @Tuplizer annotation
It is possible to map your entities as dynamic proxies using the @Tuplizer annotation.
In the following entity mapping, both the embeddable and the entity are mapped as interfaces, not POJOs.
Example : Dynamic entity proxy mapping
@Entity@Tuplizer(impl = DynamicEntityTuplizer.class)
public interface Cuisine {
@Id
@GeneratedValue
Long getId();
void setId(Long id);
String getName();
void setName(String name);
@Tuplizer(impl = DynamicEmbeddableTuplizer.class)
Country getCountry();
void setCountry(Country country);
}
@Embeddable
public interface Country {
@Column(name = "CountryName")
String getName();
void setName(String name);
}
The @Tuplizer instructs Hibernate to use the DynamicEntityTuplizer and DynamicEmbeddableTuplizer to handle the associated entity and embeddable object types.
@Tuplizers
The @Tuplizers annotation is used to group multiple @Tuplizer annotations.
Comments
Post a Comment