DetachedCriteria關聯有兩種方式ci
1. DetachedCriteria dc = DetachedCriteria.forClass(EmailPushRecord.class);
dc.setFetchMode("user", FetchMode.JOIN);
dc.setFetchMode("emailTemplate", FetchMode.JOIN); get
dc.createAlias("user", "user");
dc.createAlias("emailTemplate", "emailTemplate"); it
到了這一步下面就能夠直接用io
dc.add(Restrictions.or(class
Restrictions.like("user.name", messageReturn.getTitle(),MatchMode.ANYWHERE), Restrictions.like("emailTemplate.name", messageReturn.getTitle(),MatchMode.ANYWHERE), Restrictions.like("emailTemplate.title", messageReturn.getTitle(), MatchMode.ANYWHERE))email
);
di
2.Disjunction disjunction = Restrictions.disjunction();
DetachedCriteria dc = dc.createAlias("user", "user", CriteriaSpecification.LEFT_JOIN).createAlias("emailTemplate", "emailTemplate",CriteriaSpecification.LEFT_JOIN);mail
disjunction.add(Restrictions.or(co
Restrictions.like("user.name", messageReturn.getTitle(),MatchMode.ANYWHERE), Restrictions.like("emailTemplate.name", messageReturn.getTitle(),MatchMode.ANYWHERE), Restrictions.like("emailTemplate.title", messageReturn.getTitle(), MatchMode.ANYWHERE))message
);