0

I have two classes and relations between them. Can`t understand where the problem is. I write code in the next way.

 public class Abiturient {

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "id", nullable = false, unique = true, length = 11)
        private Long id;

        @ManyToOne(fetch = FetchType.LAZY)
        @JoinColumn(name = "prizv_id")
        private Prisvishche abiturients_pr;

And mapped one:

public class Prisvishche {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column
    private BigInteger prizv_id;

    @OneToMany(mappedBy = "prizv_id")
    private List<Abiturient> abiturients = new ArrayList();
Maciej Kowalski
  • 25,605
  • 12
  • 54
  • 63
ziki
  • 519
  • 1
  • 4
  • 8
  • did you read this linkn:https://stackoverflow.com/questions/37542208/what-is-joincolumn-and-how-it-is-used-in-hibernate – Enjy Jan 10 '18 at 19:43
  • Yes, I did, but really understanding is coming only when you improve your own error for the 3d time) thanx) – ziki Jan 11 '18 at 07:32

1 Answers1

1

You cannot point to a database column in a mappedBy. You have to point to an entity field that is the owning side of the relationship and that is:

 @ManyToOne(fetch = FetchType.LAZY)
 @JoinColumn(name = "prizv_id")
 private Prisvishche abiturients_pr;

So your owned side should be:

@OneToMany(mappedBy = "abiturients_pr")
private List<Abiturient> abiturients = new ArrayList();
Maciej Kowalski
  • 25,605
  • 12
  • 54
  • 63