fixed a bug to instantiate appropriate proxy class on foreign key access