I have an entity in Java and I would like Hibernate to create a foreign key from an Integer field (since I don't have an object reference):
@Entity
public class Invoice {
    ...
    @Column(nullable = true)
    private Integer generatedBy;
    ...
I think I'd like to do something like this with an attribute:
    @ForeignKey(name="FK_Invoice_GeneratedBy", references="UserTable.UserId")
    @Column(nullable = true)
    private Integer generatedBy;
What is the best way to achieve this? I would preferably not have to maintain these relationships in a separate file (if possible).
There doesn't seem to be a solution to this, thus accepting this as an answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With