Hibernate panache same primary key for one to one relations #25755
-
Hi My code looks like this @Entity
public class Car extends PanacheEntity {
public String plateNumber;
public String color;
@OneToOne(optional = true, mappedBy = “car”, cascade = CascadeType.REMOVE, orphanRemoval = true)
public Ownership ownership;
}
@Entity
public class Onwership extends PanacheEntity {
public String ownerName;
@OneToOne
@MapsId
@JoinColumn(name = "id")
public Car car;
} Now, when I’m trying to add ownership (persist) for an existing car, I got this |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
/cc @FroMage, @Sanne, @gsmet, @loicmathieu, @yrodiere |
Beta Was this translation helpful? Give feedback.
-
Hello, I'm guessing either It would help if you showed the actual code that persists the entities. |
Beta Was this translation helpful? Give feedback.
Hello,
I'm guessing either
Onwership#car
orCar#ownership
is null?It would help if you showed the actual code that persists the entities.