私は他の人と同じ問題を抱えています(解決されていない質問)!fetch('userWorkItems') を使用すると、生成された SQL クエリには、TbUserWorkItem に対する LEFT OUTER JOIN と JOIN の両方が含まれます。TbUserWorkItem テーブルの外部結合のみを残す必要があります。どうすればそれを解決できますか?
私の最初のモデル:
@Entity
@Table(name = "TbWorkItem", schema = "mySchema")
public class TbWorkItem extends Model {
@Id
public Integer id;
public Integer code;
/* some other properties here */
@JsonIgnore
@OneToMany//(mappedBy = "workItem")
public List<TbUserWorkItem> userWorkItems;
public static Finder<Byte, TbWorkItem> find = new Finder(Byte.class, TbWorkItem.class);
public static List<TbWorkItem> all(Integer systemId, Integer workingUserId) {
/* return find
.fetch("userWorkItems")
.where()
.eq("system.id", systemId).eq("workItemInformationType.code", 1)
.or(
Expr.eq("publicWorkItemYesNo.code", 1),
Expr.and(Expr.eq("publicWorkItemYesNo.code", 2), Expr.eq("userWorkItems.workingUserId", workingUserId)))
.findList();
*/
return find
.where()
.eq("system.id", systemId).eq("workItemInformationType.code", 1)
.or(
Expr.eq("publicWorkItemYesNo.code", 1),
Expr.and(Expr.eq("publicWorkItemYesNo.code", 2), Expr.eq("userWorkItems.workingUserId", workingUserId)))
.findList();
}
}
および 2 番目のモデル:
@Entity
@Table(name="TbUserWorkItem",schema="mySchema")
public class TbUserWorkItem extends Model {
@Id
public Integer id;
/* some properties here */
@ManyToOne
@JoinColumn(name="WorkItemId")
public TbWorkItem workItem;
public static Finder<Integer,TbUserWorkItem> find=new Finder(Integer.class,TbUserWorkItem.class);
/*some methods here*/
}