I have one @Entity class "Survey" which is having @ManyToOne relationship with "ProductSourced" @Entity class. Now "ProductSourced" can exist in same database or can come from a different database. Is it possible to create @JoinColumn such a way that first it searches in db1 and if it didnot get in db1 then it seaches primary key in db2?
Asked
Active
Viewed 24 times
0
-
You can't have relationships (foreign keys) between different databases as far as I know. Maybe you can do the join you want in a custom query – Joakim Danielson Sep 30 '19 at 10:42
-
Workarounds are possible yet risky and frail: see for example: https://stackoverflow.com/questions/4452132/add-foreign-key-relationship-between-two-databases – alainlompo Sep 30 '19 at 10:57