79222552

Date: 2024-11-25 10:12:08
Score: 1
Natty:
Report link

Try with ManyToOne and change locationId to location :

@Entity
class Location {
   @Id
   @NotNull
   private Long id;
}

class AId implements Serializable {
  private Long location;
  private String userName;
}

@Entity
@IdClass(AId.class)
class A {
    
   @Id
   private String userName
    
   @Id
   @NotNull
   @ManyToOne
   @JoinColumn(name = "location_id", nullable=false, foreignKey = @ForeignKey(name = ...))
   private Location location;
   
}

See also https://jakartaee.github.io/jakartaee-documentation/jakartaee-tutorial/9.1/persist/persistence-basicexamples/persistence-basicexamples.html

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: grigouille