Fix some bugs related to multikeys and join entity