I tried to use @Maps but it didn’t help. Still makes eager loading. Here is my code:
@SuppressWarnings("serial")
@Entity
@Table(name = "DEVICE")
public class DeviceEntity implements Serializable{
private DeviceRegistrationEntity deviceRegistration;
private Integer id;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID")
public Integer getId() {
return id;
}
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "device")
public DeviceRegistrationEntity getDeviceRegistration() {
return deviceRegistration;
}
}
@SuppressWarnings("serial")
@Entity
@Table(name = "DEVICE_REGISTRATION")
public class DeviceRegistrationEntity implements Serializable{
private DeviceEntity device;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "DEVICE_ID", insertable = false, updatable = false)
@MapsId
public DeviceEntity getDevice() {
return device;
}
public void setDevice(DeviceEntity device) {
this.device = device;
}
}
During loading DeviceEntity, it loads also the child, i.e. DeviceRegistrationEntity
Any help is appreciated.
Thanks in advance.