简体   繁体   中英

Error in mappedBy when connecting 2 users in a relationship

I have two classes, one for the user and the other for the order, my user class has roles and in the order class I want to know who was the employee and the customer who placed the order and I'm having this error mappedBy reference an unknown target entity property.

I have the following:

    User class bellow:
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    private String username;
    
    @JsonIgnore
    @NotEmpty
    private String password;
    
    @Email
    private String email;
    
    private BigDecimal balance;
    
    @JsonIgnore
    @OneToMany(mappedBy = "user")
    private List<Order> orders = new ArrayList<>();

    @ElementCollection
    @CollectionTable(name="TELEFONE")
    private Set<String> telefones = new HashSet<>();
    
    @ElementCollection(fetch=FetchType.EAGER)
    @CollectionTable(name="ROLES")
    private Set<Integer> roles = new HashSet<>();

then this

   Order class bellow:
   @Id
   @GeneratedValue(strategy = GenerationType.IDENTITY)
   private Long id;
   
   @ManyToOne
   @JoinColumn(name = "user_id")
   private User customer;
   
   @ManyToOne
   @JoinColumn(name = "user_id")
   private User employer;
   
   private Payment payment;
   
   @OneToMany(mappedBy = "id.order")
   private Set<ItemOrder> items = new HashSet<>();
   
   @JsonFormat(pattern="dd/MM/yyyy HH:mm")
   private LocalDateTime date;

Have you defined ItemOrder in a class?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM