2
我有像其他人一樣的問題(沒有解決的問題)! 當我使用fetch('userWorkItems')時,生成的sql查詢將同時具有LEFT OUTER JOIN和JOIN,通過TbUserWorkItem。 我只需要在TbUserWorkItem表中留下外連接! 我該如何解決這個問題?左外連接Ebean查詢
我的第一個型號:
@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();
}
}
和第二型號:
@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*/
}