0

Here is the code:

@Entity
@Table(name = "students")
public class BotUser {

    ...

    @Id
    @Column(name = "id", updatable = false)
    private int id;    

    @OneToOne
    private Equipment equipment;

    ...

}

@Entity
@Table(name = "students")
public class Equipment {

    ...

    @Id
    @Column(name = "id")
    private int id;

    ...

}

When Hibernate is fetching equipment data from PostrgeSQL table, he requests "equipment_id" field, not "id". How to solve this problem?

1 Answers1

0

I must use @JoinColumn annotation. And to be sure I added CascadeType.ALL

@Entity
@Table(name = "students")
public class BotUser {

    ...   

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "id")
    private Equipment equipment;

    ...

}

The same problem: AnnotationException Referenced property not a (One|Many)ToOne