package com.example;
import jakarta.persistence.*;
import java.io.Serializable;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
@Entity
@Table(name = "TEST_PARENT_TABLE", schema = "TEST")
public class ParentEntity implements Serializable {
private Integer id;
private String name;
private ChildEntity childEntity;
@Id
@Column(name = "ID")
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true)
@PrimaryKeyJoinColumn(name = "ID")
@NotFound(action = NotFoundAction.IGNORE)
public ChildEntity getChildEntity() {
return childEntity;
}
public void setChildEntity(ChildEntity childEntity) {
this.childEntity = childEntity;
}
}