문제

Hibernate HQL 쿼리는 Select Min, Max, Count 및 기타 SQL 기능을 사용하여 지원됩니까?

처럼:

select min(p.age) from person p

감사

도움이 되었습니까?

해결책

예, min(), max() 그리고 count() HQL에서 지원됩니다.

보다 집계 기능 최대 절전 모드에서.

다른 팁

그것이 내가 최대 절전 모드에서 Max를 사용하는 방식 :

public long getNextId(){
long appId;         
try{
            Session session = HibernateUtil.getAdmSessionFactory().getCurrentSession();
            Transaction t = session.beginTransaction();
            String sequel = "Select max(JAdmAppExemptionId) from JAdmAppExemption";
            Query q = session.createQuery(sequel);
            List currentSeq = q.list();
            if(currentSeq == null){
                return appId;
            }else{
            appId = (Long)currentSeq.get(0);
            return appId+1;
            }

        }catch(Exception exc){
            System.out.print("Unable to get latestID");
            exc.printStackTrace();

        }
        return 0;

    }

일부 집계 함수가 지원됩니다 수동

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top