package com.ankurm.hibernatedemo.association; import jakarta.persistence.Entity; import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.MapsId; import jakarta.persistence.OneToOne; import jakarta.persistence.Table; /** Owning side using {@code @MapsId}: its {@code @Id} IS the {@code user_id} FK value. */ @Entity @Table(name = "mi_profile") public class MiProfile { @Id private Long id; private String bio; @MapsId @OneToOne @JoinColumn(name = "id") private MiUser user; protected MiProfile() { } public MiProfile(String bio, MiUser user) { this.bio = bio; this.user = user; } public Long getId() { return id; } }