我使用 Spring ROO ,我成功生成了查找器。问题是每个属性都在自己的菜单中,我想以一种形式生成自定义查找器。
我首先在我的实体中添加一个方法,这里是方法
public static TypedQuery<com.keyrus.outside.business.entity.Candidate> findCandidatesByCustomDataLike(String principalSkills, String university) {
if (principalSkills != null) {
principalSkills = principalSkills.replace('*', '%');
if (principalSkills.charAt(0) != '%') {
principalSkills = "%" + principalSkills;
}
if (principalSkills.charAt(principalSkills.length() - 1) != '%') {
principalSkills = principalSkills + "%";
}
}
if (university != null) {
university = university.replace('*', '%');
if (university.charAt(0) != '%') {
university = "%" + university;
}
if (university.charAt(university.length() - 1) != '%') {
university = university + "%";
}
}
EntityManager em = Candidate.entityManager();
TypedQuery<Candidate> q = em.createQuery("SELECT o FROM Candidate AS o WHERE LOWER(o.principalSkills) LIKE LOWER(:principalSkills)" +
" AND LOWER(o.university) LIKE LOWER(:university)", Candidate.class);
q.setParameter("principalSkills", principalSkills);
q.setParameter("university", university);
return q;
}
如何在 *.aj 文件中生成它?
谢谢