I am trying to enable bytecode enhancement so that I can do lazy loading for the OneToOne mappings in my entity class. This is the plugin I have added in my pom:
<plugin>
<groupId>org.hibernate.orm.tooling</groupId>
<artifactId>hibernate-enhance-maven-plugin</artifactId>
<version>4.3.11.Final</version>
<executions>
<execution>
<configuration>
<enableLazyInitialization>true</enableLazyInitialization>
</configuration>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
This is the entity class:
public class ServiceItemUnit {
@Fetch(FetchMode.SELECT)
@Convert(converter = PaymentDetailConverter.class)
@OneToOne(mappedBy = "serviceItemUnit", fetch = FetchType.LAZY)
@Cascade(CascadeType.ALL)
@LazyToOne(LazyToOneOption.NO_PROXY)
private PaymentDetail paymentDetail;
}
This is the child class:
public class PaymentDetail {
@OneToOne(fetch= FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
@JoinColumn(name = "service_item_unit_id", nullable = false, unique = true)
@JsonBackReference("service_item_unit_id")
private ServiceItemUnit serviceItemUnit;
}
I went through this article, where the author guided to use this plugin for enabling bytecode enhancement.