What is the best way to validate that a foreign key is valid with Spring Data?

21 views Asked by At

I am trying with something like this:

 @NotNull
 @ManyToOne
 @JoinColumn(name = "source_id")
 private TransactionSource transactionSource;

and when the source id to create this class is invalid it throws a PSQLException

I want to return a Bad Request Status with a message with somenthing like "source id does not exist"

0

There are 0 answers