Fix exception with reverse foreign key relation