public List<Staffing> upcoming(){
List<Staffing> staffing = new ArrayList<Staffing>();
Criteria criteria = getCriteria();
criteria.add(Restrictions.isNotNull("startDate")).add(Restrictions.le("startDate", new Date()));
criteria.add(Restrictions.isNotNull("endDate")).add(Restrictions.ge("endDate", new Date()));
criteria.add(Restrictions.eq("softDelete", false));
criteria.setProjection(Projections.projectionList().add(Projections.groupProperty("user")));
DetachedCriteria maxDateQuery = DetachedCriteria.forClass(Employee.class);
maxDateQuery.add(Restrictions.in("user",criteria.list()));
maxDateQuery.setProjection(Projections.max("endDate"));
staffing = criteria.list();
return staffing;
}
ここで私は、スタッフのリストを取得しようとしていますが、私は何が間違っているオブジェクト配列わからないの一覧を取得していますが、私は投影と間違って何かを感じています。私が試していたのは、ユーザの最大endDateに基づいてユーザとその他の説明を取得することでした。プロジェクション・グループ・戸建基準
varibaleを持つStaffing.javaがあります。Employeeユーザー(Employeeは別のクラス)... date endDate .... Date startDate、Boolean softDelete ..... String projectName ...フェッチしたいユーザーのような最大endDateにを持つユーザのための人員のリストが.... endDateにを持っている多くのプロジェクトを有していてもよく..私はこれが
public class Staffing extends BaseObject {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = -3254731507746702368L;
/** The id. */
private Long id;
/** The start date. */
private Date startDate;
/** The end date. */
private Date endDate;
/** The user. */
private Employee user;
/** The project. */
private Project project;
/**
* isDelete for soft delete of staffing.
*/
private boolean softDelete;
}
私のスタッフのクラスであるユーザー
あたりの最大endDateにしたリストを取得したいとこれは従業員クラス
public class Employee extends BaseObject implements Serializable,
Comparable<Employee>, IAuditLog {
/**
* id
*/
private Long id;
/**
* username is required field
*/
private String username;
/**
* password is required field
*/
private String password;
/**
* firstname is required field
*/
private String firstName;
/**
* lastname is required field
*/
private String lastName;
/**
* personal Email is required field
*/
private String email;
/**
* primary phone number
*/
private String phoneNumber;
/**
* permanent Address
*/
private Address permanentAddress;
/**
* gender is required field
*/
private char gender;
/**
* Date of birth is required field
*/
private Date DOB;
}
です
の解決策を見つけました!何をしたいですか ? –
私はvaribaleを持つStaffing.javaを持っていますEmployeeユーザー(Employeeは別のクラスです)... Date endDate .... Date startDate、Boolean softDelete ..... String projectName ...私は人材のリストを取得したいユーザーがendDateを持つ多くのプロジェクトを持っている可能性があります。ユーザーあたり最大endDateを持つリストを取得したい –