Java 类org.hibernate.type.DateType 实例源码

项目:sakai    文件:ProfileDaoImpl.java   
/**
     * {@inheritDoc}
     */
public ProfileStatus getUserStatus(final String userId, final Date oldestDate) {

    HibernateCallback<ProfileStatus> hcb = session -> {
           Query q = session.getNamedQuery(QUERY_GET_USER_STATUS);
           q.setParameter(USER_UUID, userId, StringType.INSTANCE);
           q.setParameter(OLDEST_STATUS_DATE, oldestDate, DateType.INSTANCE);
           q.setMaxResults(1);
           return (ProfileStatus) q.uniqueResult();
     };

    return getHibernateTemplate().execute(hcb);
}
项目:national-biomedical-image-archive    文件:SubmissionHistoryDAOImpl.java   
/**
  * This is a helper method to call the named queries that are necessary
  * for the accrual report.  Check out SubmissionHistory.hbm.xml to see the queries.
  */
 private int findCountInTimeFrame(final String namedQuery,
                                 final Date startDate,
                                 final Date endDate,
                                 final String projectName,
                                 final String siteName) {


     return (Integer)getHibernateTemplate().execute(  
         new HibernateCallback() {

             public Object doInHibernate(Session session) throws HibernateException, SQLException {


        SQLQuery newPatientCountQuery = (SQLQuery)session.getNamedQuery(CrossDatabaseUtil.getNamedQuery(namedQuery));
        newPatientCountQuery.setParameter("projectName", projectName);
        newPatientCountQuery.setParameter("siteName", siteName);
        newPatientCountQuery.setParameter("startDate", startDate, new DateType());
        newPatientCountQuery.setParameter("endDate", endDate, new DateType());

                 List countList = newPatientCountQuery.list();
                 //assert countList.size == 1
                 return (Integer)countList.get(0);
                }
         });
}
项目:national-biomedical-image-archive    文件:SubmissionHistoryDAOImpl.java   
private List<DayCountDTO> findSubmissionDatesInTimeFrame_oracle(final Date startDate,
                                                        final Date endDate,
                                                        final String projectName,
                                                        final String siteName,
                                                        final Integer[] operationTypes) throws DataAccessException {

   return (List<DayCountDTO>)getHibernateTemplate().execute(  
   new HibernateCallback() {                
       public Object doInHibernate(Session session) throws HibernateException, SQLException {


           SQLQuery findSubmissionDatesInTimeFrameQuery = (SQLQuery)session.getNamedQuery(CrossDatabaseUtil.getNamedQuery("findSubmissionDatesInTimeFrame"));
           findSubmissionDatesInTimeFrameQuery.setParameter("projectName", projectName);
           findSubmissionDatesInTimeFrameQuery.setParameter("siteName", siteName);
           findSubmissionDatesInTimeFrameQuery.setParameter("startDate", startDate, new DateType());
           findSubmissionDatesInTimeFrameQuery.setParameter("endDate", endDate, new DateType());
           findSubmissionDatesInTimeFrameQuery.setParameterList("operationTypes", operationTypes);

           List<DayCountDTO> dayCountDtoList = new ArrayList<DayCountDTO>();
           List<Object[]> submissionDayAndCountList = (List<Object[]>)findSubmissionDatesInTimeFrameQuery.list();
           for(Object[] submissionDayAndCount : submissionDayAndCountList) {
               Date day = (Date)submissionDayAndCount[0];
               int count = (Integer)submissionDayAndCount[1];
               DayCountDTO dayCountDTO = new DayCountDTO(day, count);
               dayCountDtoList.add(dayCountDTO);
           }
           return dayCountDtoList;

       }
   });     

}
项目:resthub    文件:Handler.java   
public void applyParameters(SQLQuery query) throws SQLException {
    for (Map.Entry<QueryParameter, Object> e : parameters.entrySet()) {

        QueryParameter p = e.getKey();
        Object value = e.getValue();
        String name = p.getSqlName();

        if (value != null && p.getArray()) {

            switch (p.getType()) {
                case DATE:
                    query.setParameterList(name, (Object[]) value, new DateType());
                    break;
                case NUMBER:
                    query.setParameterList(name, (Object[]) value, new BigDecimalType());
                    break;
                case STRING:
                    query.setParameterList(name, (Object[]) value, new StringType());
                    break;
                case CLOB:
                case BLOB:
                    throw new ClientErrorException(Status.CLIENT_ERROR_BAD_REQUEST, String.format("LOBs are not supported as parameters: %s", name));
            }

        } else {

            switch (p.getType()) {
                case DATE:
                    query.setDate(name, (Date) value);
                    break;
                case NUMBER:
                    query.setBigDecimal(name, (BigDecimal) value);
                    break;
                case STRING:
                    query.setString(name, (String) value);
                    break;
                case CLOB:
                case BLOB:
                    throw new ClientErrorException(Status.CLIENT_ERROR_BAD_REQUEST, String.format("LOBs are not supported as parameters: %s", name));
            }
        }
    }
}
项目:sakai    文件:ProfileDaoImpl.java   
/**
     * {@inheritDoc}
     */
public ProfileStatus getUserStatus(final String userId, final Date oldestDate) {

    HibernateCallback<ProfileStatus> hcb = session -> {
           Query q = session.getNamedQuery(QUERY_GET_USER_STATUS);
           q.setParameter(USER_UUID, userId, StringType.INSTANCE);
           q.setParameter(OLDEST_STATUS_DATE, oldestDate, DateType.INSTANCE);
           q.setMaxResults(1);
           return (ProfileStatus) q.uniqueResult();
     };

    return getHibernateTemplate().execute(hcb);
}
项目:debop4j    文件:TimeRangeUserType.java   
@Override
public Type[] getPropertyTypes() {
    return new Type[] { DateType.INSTANCE, DateType.INSTANCE };
}
项目:jadira    文件:AbstractDateColumnMapper.java   
@Override
public final DateType getHibernateType() {
    return DateType.INSTANCE;
}