你好我尝试使用multiselect。我有这个代码。
CriteriaBuilder criteriaBuilder = getEntityManager().getCriteriaBuilder();
CriteriaQuery<SessionPersonne> criteriaQuery = criteriaBuilder.createQuery(SessionPersonne.class);
Root<SessionPersonne> sessionPersonneRoot = criteriaQuery.from(SessionPersonne.class);
criteriaQuery.multiselect(sessionPersonneRoot.get("keySessionPersonne"), sessionPersonneRoot.get("origine"));
Query query = getEntityManager().createQuery(criteriaQuery);
List<Object[]> result = query.getResultList();
for(int i = 0;i <result.size(); i++){
Object[] resultat = result.get(i);
System.out.println(resultat[0]+" "+resultat[1]);
}
但我有此错误消息:
-Exception [EclipseLink-6051] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.QueryException
Exception Description: Partial object queries are not allowed to maintain the cache or be edited. You must use dontMaintainCache().
Query: ReadAllQuery(referenceClass=SessionPersonne )
感谢您的帮助。