Looks right, but doing this on every find is going to have an impact on performance, we should ideally check the type of the primary key only once.