私はロールと呼ばれるテーブルを持っています。各ロールは、組織に属している場合があります。組織に属さない役割の値は null です。特定の組織のすべての役割、または組織がテーブル内で null である場所を検索したいと考えています。
Criteria criteria = this.sessionFactory.getCurrentSession().createCriteria(Role.class)
.add(Restrictions.or(
Restrictions.eq("organization",organization.getId()),
Restrictions.isNull("organization")));
マッピング ファイルには次のものがあります。
<many-to-one class="com.myname.models.Organization" name="organization">
<column name="organization_id" precision="22" scale="0" />
</many-to-one>
クエリを実行すると、次のようになります。
IllegalArgumentException occurred calling getter com.myname.models.Organization.id
基準を変更して組織の null を照会するだけですべてが機能することがわかりましたが、値を照会するとエラーが発生します。
目標を達成するためにクエリまたはマッピング ファイルを変更するにはどうすればよいですか?