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

项目:lams    文件:VoteUsrAttemptDAO.java   
@Override
   @SuppressWarnings("unchecked")
   public List<VoteStatsDTO> getStatisticsBySession(Long toolContentId) {

SQLQuery query = getSession().createSQLQuery(GET_STATISTICS);
query.addScalar("sessionUid", LongType.INSTANCE).addScalar("sessionName", StringType.INSTANCE)
    .addScalar("countUsersComplete", IntegerType.INSTANCE).setLong("contentId", toolContentId)
    .setResultTransformer(Transformers.aliasToBean(VoteStatsDTO.class));

return query.list();
   }
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public List<UserStatistics> findAuthoredStatsForStudentByForumId(final String studentId, final Long topicId) {
    if (log.isDebugEnabled()) log.debug("findAuthoredStatsForStudentByForumId()");

    HibernateCallback<List<Object[]>> hcb = session -> {
        Query q = session.getNamedQuery("findAuthoredStatsForStudentByForumId");
        q.setParameter("forumId", topicId, LongType.INSTANCE);
        q.setParameter("userId", studentId, StringType.INSTANCE);
        return q.list();
    };
    List<UserStatistics> returnList = new ArrayList<UserStatistics>();
    List<Object[]> results = getHibernateTemplate().execute(hcb);
    for(Object[] result : results){
        UserStatistics stat = new UserStatistics((String) result[0], (String) result[1], (Date) result[2], (String) result[3], 
                ((Integer) result[4]).toString(), ((Integer) result[5]).toString(), ((Integer) result[6]).toString(), studentId);
        returnList.add(stat);
    }
    return returnList;
}
项目:unitimes    文件:SessionRestore.java   
protected Object get(Class clazz, String id) {
    if (clazz.equals(String.class) || clazz.equals(StringType.class)) return id;
    if (clazz.equals(Character.class) || clazz.equals(CharacterType.class)) return (id == null || id.isEmpty() ? null : id.charAt(0));
    if (clazz.equals(Byte.class) || clazz.equals(ByteType.class)) return Byte.valueOf(id);
    if (clazz.equals(Short.class) || clazz.equals(ShortType.class)) return Short.valueOf(id);
    if (clazz.equals(Integer.class) || clazz.equals(IntegerType.class)) return Integer.valueOf(id);
    if (clazz.equals(Long.class) || clazz.equals(LongType.class)) return Long.valueOf(id);
    if (clazz.equals(Float.class) || clazz.equals(FloatType.class)) return Float.valueOf(id);
    if (clazz.equals(Double.class) || clazz.equals(DoubleType.class)) return Double.valueOf(id);
    if (clazz.equals(Boolean.class) || clazz.equals(BooleanType.class)) return Boolean.valueOf(id);

    Map<String, Entity> entities = iEntities.get(clazz.getName());
    if (entities != null) {
        Entity entity = entities.get(id);
        if (entity != null) return entity.getObject();
    }
       for (Map.Entry<String, Map<String, Entity>> entry: iEntities.entrySet()) {
        Entity o = entry.getValue().get(id);
        if (o != null && clazz.isInstance(o.getObject())) return o.getObject();
    }
       if (clazz.equals(Session.class))
        return ((Entity)iEntities.get(Session.class.getName()).values().iterator().next()).getObject();
       if (clazz.equals(Student.class))
        return checkUnknown(clazz, id, iStudents.get(id));
       if (iIsClone)
        return checkUnknown(clazz, id,
                iHibSession.get(clazz, clazz.equals(ItypeDesc.class) ? (Serializable) Integer.valueOf(id) : (Serializable) Long.valueOf(id)));
       return checkUnknown(clazz, id, null);
}
项目:bootstrap    文件:SequenceIdentifierGeneratorStrategyProviderTest.java   
/**
 * Check strategy configuration.
 */
@Test
public void testConfiguration() {
    final Properties params = new Properties();
    params.put("identity_tables", "summy.seg");
    params.put(PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER, new ObjectNameNormalizer() {

        @Override
        protected MetadataBuildingContext getBuildingContext() {
            return null;
        }
    });

    OptimizedSequenceStyleGenerator optimizedSequenceStyleGenerator = newStyleGenerator();
    optimizedSequenceStyleGenerator.configure(StringType.INSTANCE, params, newServiceRegistry());
}
项目:hibernate-single-table-bulk-id-strategy    文件:SingleGlobalTemporaryTableBulkIdStrategy.java   
private void cleanUpRows(SharedSessionContractImplementor session, Queryable persister) {
    final String sql = "delete from " + fullyQualifiedTableName + " where " + discriminatorColumn + "=?";
    PreparedStatement ps = null;
    try {
        ps = session.getJdbcCoordinator().getStatementPreparer().prepareStatement(sql, false);
        ps.setString(1, generateDiscriminatorValue(persister));
        StringType.INSTANCE.set(ps, generateDiscriminatorValue(persister), 1, session);
        session.getJdbcCoordinator().getResultSetReturn().executeUpdate(ps);
    } catch (SQLException e) {
        throw session.getJdbcServices().getSqlExceptionHelper().convert(e, "Unable to clean up id table [" + fullyQualifiedTableName + "]", sql);
    } finally {
        if (ps != null) {
            session.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release(ps);
        }
    }
}
项目:dkpro-jwpl    文件:Wikipedia.java   
/**
 * Gets the page ids for a given title.<br>
 *
 *
 * @param title The title of the page.
 * @return The id for the page with the given title.
 * @throws WikiApiException
 */
public List<Integer> getPageIds(String title) throws WikiApiException {
    Session session = this.__getHibernateSession();
    session.beginTransaction();
    Iterator results = session.createQuery(
    "select p.pageID from PageMapLine as p where p.name = :pName").setParameter("pName", title, StringType.INSTANCE).list().iterator();

    session.getTransaction().commit();

    if(!results.hasNext()){
        throw new WikiPageNotFoundException();
    }
    List<Integer> resultList = new LinkedList<Integer>();
    while(results.hasNext()){
        resultList.add((Integer)results.next());
    }
    return resultList;
}
项目:sakai    文件:SyllabusManagerImpl.java   
/**
 * getSyllabusItemByContextId finds a SyllabusItem
 * @param contextId
 * @return SyllabusItem
 *        
 */
public SyllabusItem getSyllabusItemByContextId(final String contextId)
{
  if (contextId == null)
  {
    throw new IllegalArgumentException("Null Argument");
  }

  HibernateCallback<SyllabusItem> hcb = session -> {
    Query q = session.getNamedQuery(QUERY_BY_CONTEXTID);
    q.setParameter(CONTEXT_ID, contextId, StringType.INSTANCE);
    return (SyllabusItem) q.uniqueResult();
  };

  return getHibernateTemplate().execute(hcb);
}
项目:dkpro-jwpl    文件:Category.java   
/**
 * @see de.tudarmstadt.ukp.wikipedia.api.Category#Category(Wikipedia, String)
 */
private void createCategory(Title title) throws WikiPageNotFoundException {
    String name = title.getWikiStyleTitle();
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();

    Object returnValue;
    returnValue = session.createNativeQuery(
            "select cat.pageId from Category as cat where cat.name = :name COLLATE utf8_bin")
            .setParameter("name", name, StringType.INSTANCE)
            .uniqueResult();
    session.getTransaction().commit();

    // if there is no category with this name, the hibernateCategory is null
    if (returnValue == null) {
        hibernateCategory = null;
        throw new WikiPageNotFoundException("No category with name " + name + " was found.");
    }
    else {
        // now cast it into an integer
        int pageID = (Integer) returnValue;
        createCategory( pageID);
    }
}
项目:metaworks_framework    文件:TranslationServiceImpl.java   
protected String getEntityId(Object entity, TranslatedEntity entityType) {
    Map<String, Object> idMetadata = dao.getIdPropertyMetadata(entityType);
    String idProperty = (String) idMetadata.get("name");
    Type idType = (Type) idMetadata.get("type");

    if (!(idType instanceof LongType || idType instanceof StringType)) {
        throw new UnsupportedOperationException("Only ID types of String and Long are currently supported");
    }

    Object idValue = null;
    try {
        idValue = PropertyUtils.getProperty(entity, idProperty);
    } catch (Exception e) {
        throw new RuntimeException("Error reading id property", e);
    }

    if (idType instanceof StringType) {
        return (String) idValue;
    } else if (idType instanceof LongType) {
        return String.valueOf(idValue);
    }

    throw new IllegalArgumentException(String.format("Could not retrieve value for id property. Object: [%s], " +
            "ID Property: [%s], ID Type: [%s]", entity, idProperty, idType));
}
项目:sakai    文件:LinkManagerImpl.java   
public List<Link> getLinks(final String activityRef, final boolean any,
        final String context) {
    if ((activityRef == null) || (context == null)) {
        throw new IllegalArgumentException(NULL_ARG);
    }

    return getHibernateTemplate().execute((HibernateCallback<List<Link>>) session -> {
           String likeContext = "%/"+context+"/%";

           Query q = session.getNamedQuery(QUERY_LINKS_BY_ACTIVITY_CONTEXT);
           if (!any) {
               q = session.getNamedQuery(QUERY_LINKS_BY_ACTIVITY_CONTEXT_VISIBLE);
               q.setParameter(VISIBLE, true);
           }

           q.setParameter(ACTIVITY_REF, activityRef, StringType.INSTANCE);
           q.setParameter(CONTEXT, likeContext, StringType.INSTANCE);

           return q.list();
       });
}
项目:sakai    文件:SakaiPersonManagerImpl.java   
private List<SakaiPerson> listSakaiPersons(final Collection<String> userIds, final Type recordType)
{
    final HibernateCallback hcb = new HibernateCallback()
    {
        public Object doInHibernate(Session session) throws HibernateException
        {
            Query q = session.getNamedQuery(HQL_FIND_SAKAI_PERSONS_BY_AGENTS_AND_TYPE);
            q.setParameterList(AGENT_UUID_COLLECTION, userIds);
            q.setParameter(TYPE_UUID, recordType.getUuid(), StringType.INSTANCE);
            // q.setCacheable(false);
            return q.list();
        }
    };
    List hb =  (List) getHibernateTemplate().execute(hcb);
    if (photoService.overRidesDefault()) {
        return getDiskPhotosForList(hb);
    } else {
        return hb;
    }
}
项目:sakai    文件:AssignmentDataProvider11.java   
@Override
@Transactional(readOnly = true)
public List<String> fetchAssignmentsToConvert() {
    List<String> list;
    try {
        list = sessionFactory.getCurrentSession()
                .createSQLQuery("SELECT ASSIGNMENT_ID FROM ASSIGNMENT_ASSIGNMENT")
                .addScalar("ASSIGNMENT_ID", StringType.INSTANCE)
                .list();

        return list;
    } catch (Exception e) {
        log.warn("could not query table ASSIGNMENT_ASSIGNMENT for assignments to migrate, {}", e.getMessage());
    }
    return Collections.emptyList();
}
项目:sakai    文件:AssignmentDataProvider11.java   
@Override
@Transactional(readOnly = true)
public String fetchAssignment(String assignmentId) {
    try {
        String xml = (String) sessionFactory.getCurrentSession()
                .createSQLQuery("SELECT XML FROM ASSIGNMENT_ASSIGNMENT WHERE ASSIGNMENT_ID = :id")
                .addScalar("XML", StringType.INSTANCE)
                .setParameter("id", assignmentId, StringType.INSTANCE)
                .uniqueResult();

        return xml;
    } catch (Exception e) {
        log.warn("could not query table ASSIGNMENT_ASSIGNMENT for assignment {}, {}", assignmentId, e.getMessage());
    }
    return null;
}
项目:sakai    文件:LinkManagerImpl.java   
public List<Link> getLinks(final String criteriaRef, final boolean any) {
    if (criteriaRef == null) {
        throw new IllegalArgumentException(NULL_ARG);
    }

    return getHibernateTemplate().execute((HibernateCallback<List<Link>>) session -> {

           Query q = session.getNamedQuery(QUERY_LINKS_BY_CRITERIA);
           if (!any) {
               q = session.getNamedQuery(QUERY_LINKS_BY_CRITERIA_VISIBLE);
               q.setParameter(VISIBLE, true);
           }

           q.setParameter(TAG_CRITERIA_REF, criteriaRef, StringType.INSTANCE);

           return q.list();
       });
}
项目:sakai    文件:AssignmentDataProvider11.java   
@Override
@Transactional(readOnly = true)
public List<String> fetchAssignmentSubmissions(String assignmentId) {
    try {
        List<String> list = sessionFactory.getCurrentSession()
                .createSQLQuery("SELECT XML FROM ASSIGNMENT_SUBMISSION WHERE CONTEXT = :id")
                .addScalar("XML", StringType.INSTANCE)
                .setParameter("id", assignmentId, StringType.INSTANCE)
                .list();

        return list;
    } catch (Exception e) {
        log.warn("could not query table ASSIGNMENT_SUBMISSION for submissions to migrate, {}", e.getMessage());
    }
    return Collections.emptyList();
}
项目:sakai    文件:ProfileDaoImpl.java   
/**
     * {@inheritDoc}
     */
public List<String> getRequestedConnectionUserIdsForUser(final String userId) {

    //get friends of this user [and map it automatically to the Friend object]
    //updated: now just returns a List of Strings
    HibernateCallback<List<String>> hcb = session -> {
           Query q = session.getNamedQuery(QUERY_GET_FRIEND_REQUESTS_FOR_USER);
           q.setParameter(USER_UUID, userId, StringType.INSTANCE);
           q.setBoolean("false", Boolean.FALSE);
           //q.setResultTransformer(Transformers.aliasToBean(Friend.class));

           return q.list();
       };

    return getHibernateTemplate().execute(hcb);
}
项目:sakai    文件:ProfileDaoImpl.java   
/**
     * {@inheritDoc}
     */
public List<String> findSakaiPersonsByInterest(final String search, final boolean includeBusinessBio) {

    //get 
    HibernateCallback<List<String>> hcb = session -> {
           Query q;
           if (false == includeBusinessBio) {
               q = session.getNamedQuery(QUERY_FIND_SAKAI_PERSONS_BY_INTEREST);
           } else {
               q = session.getNamedQuery(QUERY_FIND_SAKAI_PERSONS_BY_INTEREST_AND_BUSINESS_BIO);
           }
           q.setParameter(SEARCH, '%' + search + '%', StringType.INSTANCE);
           return q.list();
       };

    return getHibernateTemplate().execute(hcb);
}
项目:sakai    文件:RandomisedUrlService.java   
/**
 * Checks if a given key is unique by checking for its existence
 * @param key
 * @return
 */
private boolean isKeyUnique(final String key) {

    RandomisedUrl randomisedUrl = null;

    HibernateCallback<RandomisedUrl> hcb = session -> {
           Query q = session.getNamedQuery(QUERY_GET_URL);
           q.setParameter(KEY, key, StringType.INSTANCE);
           q.setMaxResults(1);
           return (RandomisedUrl) q.uniqueResult();
     };

    //if null then it doesn't exist
    randomisedUrl = getHibernateTemplate().execute(hcb);
    if(randomisedUrl == null) {
        return true;
    }
    return false;
}
项目:solidsearch-bot    文件:URLRestManager.java   
private void addScalars(SQLQuery query)
{
    query.addScalar("URI", StringType.INSTANCE);
    query.addScalar("foundTimestamp", LongType.INSTANCE);
    query.addScalar("canonicalTag", StringType.INSTANCE);
    query.addScalar("httpStatusCode", IntegerType.INSTANCE);
    query.addScalar("lastCrawledTimestamp", LongType.INSTANCE);
    query.addScalar("contentHashcode", StringType.INSTANCE);
    query.addScalar("backgroundId", ShortType.INSTANCE);
    query.addScalar("qualityScore", ShortType.INSTANCE);
    query.addScalar("spamScore", ShortType.INSTANCE);
    query.addScalar("readingLevel", ShortType.INSTANCE);
    query.addScalar("varietyTopicScore", ShortType.INSTANCE);
    query.addScalar("adScripts", ShortType.INSTANCE);
    query.addScalar("relevantImages", BooleanType.INSTANCE);
    query.addScalar("responseTime", IntegerType.INSTANCE);
    query.addScalar("pageSize", IntegerType.INSTANCE);
    query.addScalar("pageRank", DoubleType.INSTANCE);
    query.addScalar("qwLocale", StringType.INSTANCE);
    query.addScalar("onPageText", StringType.INSTANCE);
    query.addScalar("title", StringType.INSTANCE);
    query.addScalar("metaDescription", StringType.INSTANCE);
    query.addScalar("topicKeyword", StringType.INSTANCE);
    query.addScalar("robotsIndex", BooleanType.INSTANCE);
    query.addScalar("duplicateTitle", BooleanType.INSTANCE);
    query.addScalar("duplicateMetaDescription", BooleanType.INSTANCE);
    query.addScalar("duplicateContent", BooleanType.INSTANCE);
    query.addScalar("trailingSlashIssue", BooleanType.INSTANCE);
    query.addScalar("timeout", BooleanType.INSTANCE);
    query.addScalar("pagination", BooleanType.INSTANCE);
    query.addScalar("dcPrimary", BooleanType.INSTANCE);
}
项目: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);
}
项目:solidsearch-bot    文件:DomainRestManager.java   
private void addScalars(SQLQuery query)
{
    query.addScalar("resultFromTimestampMills", LongType.INSTANCE);
    query.addScalar("qualityScore", ShortType.INSTANCE);
    query.addScalar("totalLinks", LongType.INSTANCE);
    query.addScalar("internalURLs", LongType.INSTANCE);
    query.addScalar("internalNoindexURLs", LongType.INSTANCE);
    query.addScalar("internalIndexURLs", LongType.INSTANCE);
    query.addScalar("externalURLs", LongType.INSTANCE);
    query.addScalar("externalURLsDifferentDomains", LongType.INSTANCE);
    query.addScalar("crawledURLs", LongType.INSTANCE);
    query.addScalar("clientErrorURLs", LongType.INSTANCE);
    query.addScalar("timeoutURLs", LongType.INSTANCE);
    query.addScalar("redirectionURLs", LongType.INSTANCE);
    query.addScalar("serverErrorURLs", LongType.INSTANCE);
    query.addScalar("avgResponseTimeMills", IntegerType.INSTANCE);
    query.addScalar("medianResponseTimeMills", IntegerType.INSTANCE);
    query.addScalar("avgPageSize", LongType.INSTANCE);
    query.addScalar("totalCountOfRelevantKeywords", LongType.INSTANCE);
    query.addScalar("totalCountOfKeywords", LongType.INSTANCE);
    query.addScalar("avgReadingLevel", DoubleType.INSTANCE);
    query.addScalar("domainBrandName", StringType.INSTANCE);
    query.addScalar("homeDocument", StringType.INSTANCE);
}
项目:sakai    文件:ExtendedTimeQueries.java   
@SuppressWarnings("unchecked")
private ExtendedTime        getPubAndX              (final String query, final PublishedAssessmentIfc pub, final String secondParam, final String secondParamValue) {
    try{
        HibernateCallback hcb = (Session s) -> {
            Query q = s.getNamedQuery(query);
            q.setParameter(PUBLISHED_ID, pub, new ManyToOneType(null, "org.sakaiproject.tool.assessment.data.dao.assessment.PublishedAssessmentData"));
            q.setParameter(secondParam, secondParamValue, new StringType());
            return q.uniqueResult();
        };

        return (ExtendedTime) getHibernateTemplate().execute(hcb);
    } catch (DataAccessException e) {
        log.error("Failed to get extended time for pub: " + pub.getPublishedAssessmentId() + " and user/group: " + secondParamValue, e);
        return null;
    }
}
项目:sakai    文件:AnonymousManagerImpl.java   
/** {@inheritDoc} */
public Map<String, String> getUserIdAnonIdMap(final String siteId)
{
    Map<String, String> anonIdMap = new HashMap<>();

    HibernateCallback<List<AnonymousMapping>> hcb = new HibernateCallback<List<AnonymousMapping>>()
    {
        public List<AnonymousMapping> doInHibernate(Session session) throws HibernateException
        {
            Query q = session.getNamedQuery(QUERY_BY_SITE);
            q.setParameter("siteId", siteId, StringType.INSTANCE);
            return q.list();
        }
    };

    List<AnonymousMapping> mappings = getHibernateTemplate().execute(hcb);

    for (AnonymousMapping mapping : mappings)
    {
        anonIdMap.put(mapping.getUserId(), mapping.getAnonId());
    }

    return anonIdMap;
}
项目:sakai    文件:SynopticMsgcntrManagerImpl.java   
public List<SynopticMsgcntrItem> getSiteSynopticMsgcntrItems(final List<String> userIds, final String siteId) {
    if(userIds == null || userIds.size() == 0){
        return new ArrayList<SynopticMsgcntrItem>();
    }
    HibernateCallback<List<SynopticMsgcntrItem>> hcb = session -> {
           List rtn = new ArrayList();
           Query q = session.getNamedQuery(QUERY_SITE_SYNOPTIC_ITEMS);
           q.setParameter("siteId", siteId, StringType.INSTANCE);
           for (int initIndex = 0; initIndex < userIds.size(); initIndex+=ORACLE_IN_CLAUSE_SIZE_LIMIT) {
               q.setParameterList("userIds", userIds.subList(initIndex, Math.min(initIndex+ORACLE_IN_CLAUSE_SIZE_LIMIT, userIds.size())));
               rtn.addAll(q.list());
           }
           return rtn;
       };

    return getHibernateTemplate().execute(hcb);
}
项目:sakai    文件:RankManagerImpl.java   
public List getRankList(final String contextId) {
    if (log.isDebugEnabled()) {
        log.debug("getRank(contextId: " + contextId + ")");
    }
    if (contextId == null) {
        throw new IllegalArgumentException("Null Argument");
    }
    if (!isRanksEnabled())
    {
        return new ArrayList();
    }
    HibernateCallback<List> hcb = session -> {
        Query q = session.getNamedQuery(QUERY_BY_CONTEXT_ID);
        q.setParameter("contextId", contextId, StringType.INSTANCE);
        return q.list();
    };

    return getHibernateTemplate().execute(hcb);
}
项目:sakai    文件:RankManagerImpl.java   
public List findRanksByContextIdOrderByMinPostDesc(final String contextId) {
    if (log.isDebugEnabled()) {
        log.debug("getRank(contextId: " + contextId + ")");
    }

    if (contextId == null) {
        throw new IllegalArgumentException("Null Argument");
    }

    if (!isRanksEnabled())
    {
        return new ArrayList();
    }

    HibernateCallback<List> hcb = session -> {
        Query q = session.getNamedQuery(QUERY_BY_CONTEXT_ID_ORDER_BY_MIN_POST_DESC);
        q.setParameter("contextId", contextId, StringType.INSTANCE);
        return q.list();
    };

    return getHibernateTemplate().execute(hcb);
}
项目:sakai    文件:SyllabusManagerImpl.java   
/**
 * getSyllabusItemByUserAndContextIds finds a SyllabusItem
 * @param userId
 * @param contextId
 * @return SyllabusItem
 *        
 */
public SyllabusItem getSyllabusItemByUserAndContextIds(final String userId, final String contextId)
{
  if (userId == null || contextId == null)
  {
    throw new IllegalArgumentException("Null Argument");
  }

  HibernateCallback<SyllabusItem> hcb = session -> {
    Query q = session.getNamedQuery(QUERY_BY_USERID_AND_CONTEXTID);
    q.setParameter(USER_ID, userId, StringType.INSTANCE);
    q.setParameter(CONTEXT_ID, contextId, StringType.INSTANCE);
    return (SyllabusItem) q.uniqueResult();
  };

  return getHibernateTemplate().execute(hcb);
}
项目:sakai    文件:RankManagerImpl.java   
public List findRanksByContextIdBasedOnNumPost(final String contextId) {
    if (log.isDebugEnabled()) {
        log.debug("findRanksByContextIdBasedOnNumPost(contextId: " + contextId + ")");
    }

    if (contextId == null) {
        throw new IllegalArgumentException("Null Argument");
    }

    if (!isRanksEnabled())
    {
        return new ArrayList();
    }

    HibernateCallback<List> hcb = session -> {
        Query q = session.getNamedQuery(QUERY_BY_CONTEXT_ID_NUM_POSTS_BASED);
        q.setParameter("contextId", contextId, StringType.INSTANCE);
        return q.list();
    };

    return getHibernateTemplate().execute(hcb);
}
项目:sakai    文件:PrivateMessageManagerImpl.java   
/**
 * helper method to get messages by type
 * @param typeUuid
 * @return message list
 */
public List getMessagesByType(final String typeUuid, final String orderField,
    final String order)
{

  if (log.isDebugEnabled())
  {
    log.debug("getMessagesByType(typeUuid:" + typeUuid + ", orderField: "
        + orderField + ", order:" + order + ")");
  }

  HibernateCallback<List> hcb = session -> {
    Query q = session.getNamedQuery(QUERY_MESSAGES_BY_USER_TYPE_AND_CONTEXT);
    Query qOrdered = session.createQuery(q.getQueryString() + " order by "
        + orderField + " " + order);

    qOrdered.setParameter("userId", getCurrentUser(), StringType.INSTANCE);
    qOrdered.setParameter("typeUuid", typeUuid, StringType.INSTANCE);
    qOrdered.setParameter("contextId", getContextId(), StringType.INSTANCE);
    return qOrdered.list();
  };

  return getHibernateTemplate().execute(hcb);
}
项目:sakai    文件:PrivateMessageManagerImpl.java   
/**
 * FOR SYNOPTIC TOOL:
 *  helper method to get messages by type
 *  needed to pass contextId since could be in MyWorkspace
 * 
 * @param typeUuid
 *          The type of forum it is (Private or Topic)
 * @param contextId
 *          The site id whose messages are needed
 * 
 * @return message list
 */
public List getMessagesByTypeByContext(final String typeUuid, final String contextId)
{

  if (log.isDebugEnabled())
  {
    log.debug("getMessagesByTypeForASite(typeUuid:" + typeUuid + ")");
  }

  HibernateCallback<List> hcb = session -> {
    Query q = session.getNamedQuery(QUERY_MESSAGES_BY_USER_TYPE_AND_CONTEXT);

    q.setParameter("userId", getCurrentUser(), StringType.INSTANCE);
    q.setParameter("typeUuid", typeUuid, StringType.INSTANCE);
    q.setParameter("contextId", contextId, StringType.INSTANCE);
    return q.list();
  };

  return getHibernateTemplate().execute(hcb);
}
项目:sakai    文件:PrivateMessageManagerImpl.java   
public List getMessagesByTypeByContext(final String typeUuid, final String contextId, final String userId, final String orderField,
     final String order){
  if (log.isDebugEnabled())
  {
    log.debug("getMessagesByTypeForASite(typeUuid:" + typeUuid + ")");
  }

  HibernateCallback<List> hcb = session -> {
    Query q = session.getNamedQuery(QUERY_MESSAGES_BY_USER_TYPE_AND_CONTEXT);
    Query qOrdered = session.createQuery(q.getQueryString() + " order by "
            + orderField + " " + order);
    qOrdered.setParameter("userId", userId, StringType.INSTANCE);
    qOrdered.setParameter("typeUuid", typeUuid, StringType.INSTANCE);
    qOrdered.setParameter("contextId", contextId, StringType.INSTANCE);
    return qOrdered.list();
  };

  return getHibernateTemplate().execute(hcb);
}
项目:sakai    文件:PrivateMessageManagerImpl.java   
private List initializeMessageCounts(final String userId, final String contextId)
{
  if (log.isDebugEnabled())
  {
    log.debug("initializeMessageCounts executing");
  }

  HibernateCallback<List> hcb = session -> {
    Query q = session.getNamedQuery(QUERY_AGGREGATE_COUNT);
    q.setParameter("contextId", contextId, StringType.INSTANCE);
    q.setParameter("userId", userId, StringType.INSTANCE);
    return q.list();
  };

  return getHibernateTemplate().execute(hcb);
}
项目:hql-builder    文件:HqlServiceImpl.java   
@SuppressWarnings("unchecked")
@Override
public <T extends Serializable, I extends Serializable> T get(Class<T> type, I id) {
    Object idv = id;
    String name = type.getName();
    ClassMetadata classMetadata = (ClassMetadata) new MetadataResolver().getAllClassMetadata(sessionFactory).get(name);
    String oid = classMetadata.getIdentifierPropertyName();
    if (id instanceof String) {
        IdentifierType<?> identifierType = (IdentifierType<?>) classMetadata.getIdentifierType();
        if (!(identifierType instanceof StringType)) {
            try {
                idv = identifierType.stringToObject((String) id);
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        }
    }
    QueryParameters hql = new QueryParameters("from " + name + " where " + oid + "=:" + oid,
            new QueryParameter().setName(oid).setValueTypeText(idv));
    logger.debug("hql={}", hql);
    List<Serializable> value = execute(hql).getResults().getValue();
    return (T) (value.isEmpty() ? null : value.get(0));
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public List<UserStatistics> findAuthoredStatsForStudent(final String studentId) {
  if (log.isDebugEnabled()) log.debug("findAuthoredStatsForStudent()");

  HibernateCallback<List<Object[]>> hcb = session -> {
      Query q = session.getNamedQuery("findAuthoredStatsForStudent");
      q.setParameter("contextId", getContextId(), StringType.INSTANCE);
      q.setParameter("userId", studentId, StringType.INSTANCE);
      return q.list();
  };
  List<UserStatistics> returnList = new ArrayList<UserStatistics>();
  List<Object[]> results = getHibernateTemplate().execute(hcb);
  for(Object[] result : results){
      UserStatistics stat = new UserStatistics((String) result[0], (String) result[1], (Date) result[2], (String) result[3], 
              ((Integer) result[4]).toString(), ((Integer) result[5]).toString(), ((Integer) result[6]).toString(), studentId);
      returnList.add(stat);
  }
  return returnList;
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public List<UserStatistics> findAuthoredStatsForStudentByTopicId(final String studentId, final Long topicId) {
    if (log.isDebugEnabled()) log.debug("findAuthoredStatsForStudentByTopicId()");

    HibernateCallback hcb = session -> {
        Query q = session.getNamedQuery("findAuthoredStatsForStudentByTopicId");
        q.setParameter("topicId", topicId, LongType.INSTANCE);
        q.setParameter("userId", studentId, StringType.INSTANCE);
        return q.list();
    };
    List<UserStatistics> returnList = new ArrayList<UserStatistics>();
    List<Object[]> results = (List<Object[]>)getHibernateTemplate().execute(hcb);
    for(Object[] result : results){
        UserStatistics stat = new UserStatistics((String) result[0], (String) result[1], (Date) result[2], (String) result[3], 
                ((Integer) result[4]).toString(), ((Integer) result[5]).toString(), ((Integer) result[6]).toString(), studentId);
        returnList.add(stat);
    }
    return returnList;
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public List<UserStatistics> findReadStatsForStudent(final String studentId) {
  if (log.isDebugEnabled()) log.debug("findReadStatsForStudent()");

  HibernateCallback<List<Object[]>> hcb = session -> {
      Query q = session.getNamedQuery("findReadStatsForStudent");
      q.setParameter("contextId", getContextId(), StringType.INSTANCE);
      q.setParameter("userId", studentId, StringType.INSTANCE);
      return q.list();
  };
  List<UserStatistics> returnList = new ArrayList<UserStatistics>();
  List<Object[]> results = getHibernateTemplate().execute(hcb);
  for(Object[] result : results){
      UserStatistics stat = new UserStatistics((String) result[0], (String) result[1], (Date) result[2], (String) result[3], 
              ((Integer) result[4]).toString(), ((Integer) result[5]).toString(), ((Integer) result[6]).toString(), studentId);
      returnList.add(stat);
  }
  return returnList;
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public List<UserStatistics> findReadStatsForStudentByForumId(final String studentId, final Long forumId) {
    if (log.isDebugEnabled()) log.debug("findReadStatsForStudentByForumId()");

    HibernateCallback<List<Object[]>> hcb = session -> {
        Query q = session.getNamedQuery("findReadStatsForStudentByForumId");
        q.setParameter("userId", studentId, StringType.INSTANCE);
        q.setParameter("forumId", forumId, LongType.INSTANCE);
        return q.list();
    };
    List<UserStatistics> returnList = new ArrayList<UserStatistics>();
    List<Object[]> results = getHibernateTemplate().execute(hcb);
    for(Object[] result : results){
      UserStatistics stat = new UserStatistics((String) result[0], (String) result[1], (Date) result[2], (String) result[3], 
              ((Integer) result[4]).toString(), ((Integer) result[5]).toString(), ((Integer) result[6]).toString(), studentId);
      returnList.add(stat);
    }
    return returnList;
}
项目:blcdemo    文件:TranslationDaoImpl.java   
@Override
public String getEntityId(TranslatedEntity entityType, Object entity) {
    Map<String, Object> idMetadata = getIdPropertyMetadata(entityType);
    String idProperty = (String) idMetadata.get("name");
    Type idType = (Type) idMetadata.get("type");

    if (!(idType instanceof LongType || idType instanceof StringType)) {
        throw new UnsupportedOperationException("Only ID types of String and Long are currently supported");
    }

    Object idValue;
    try {
        idValue = PropertyUtils.getProperty(entity, idProperty);
    } catch (Exception e) {
        throw new RuntimeException("Error reading id property", e);
    }

    if (idType instanceof StringType) {
        return (String) idValue;
    } else if (idType instanceof LongType) {
        return getUpdatedEntityId(entityType, (Long) idValue);
    }

    throw new IllegalArgumentException(String.format("Could not retrieve value for id property. Object: [%s], " +
            "ID Property: [%s], ID Type: [%s]", entity, idProperty, idType));
}
项目:amv-access-api-poc    文件:SQLiteDialect.java   
public SQLiteDialect() {
    registerColumnType(Types.BIT, "integer");
    registerColumnType(Types.TINYINT, "tinyint");
    registerColumnType(Types.SMALLINT, "smallint");
    registerColumnType(Types.INTEGER, "integer");
    registerColumnType(Types.BIGINT, "bigint");
    registerColumnType(Types.FLOAT, "float");
    registerColumnType(Types.REAL, "real");
    registerColumnType(Types.DOUBLE, "double");
    registerColumnType(Types.NUMERIC, "numeric");
    registerColumnType(Types.DECIMAL, "decimal");
    registerColumnType(Types.CHAR, "char");
    registerColumnType(Types.VARCHAR, "varchar");
    registerColumnType(Types.LONGVARCHAR, "longvarchar");
    registerColumnType(Types.DATE, "date");
    registerColumnType(Types.TIME, "time");
    registerColumnType(Types.TIMESTAMP, "timestamp");
    registerColumnType(Types.BINARY, "blob");
    registerColumnType(Types.VARBINARY, "blob");
    registerColumnType(Types.LONGVARBINARY, "blob");
    // registerColumnType(Types.NULL, "null");
    registerColumnType(Types.BLOB, "blob");
    registerColumnType(Types.CLOB, "clob");
    registerColumnType(Types.BOOLEAN, "integer");

    registerFunction("concat", new VarArgsSQLFunction(StringType.INSTANCE, "", "||", ""));
    registerFunction("mod", new SQLFunctionTemplate(StringType.INSTANCE, "?1 % ?2"));
    registerFunction("substr", new StandardSQLFunction("substr", StringType.INSTANCE));
    registerFunction("substring", new StandardSQLFunction("substr", StringType.INSTANCE));
}
项目:amv-access-api-poc    文件:SQLiteDialect.java   
public SQLiteDialect() {
    registerColumnType(Types.BIT, "integer");
    registerColumnType(Types.TINYINT, "tinyint");
    registerColumnType(Types.SMALLINT, "smallint");
    registerColumnType(Types.INTEGER, "integer");
    registerColumnType(Types.BIGINT, "bigint");
    registerColumnType(Types.FLOAT, "float");
    registerColumnType(Types.REAL, "real");
    registerColumnType(Types.DOUBLE, "double");
    registerColumnType(Types.NUMERIC, "numeric");
    registerColumnType(Types.DECIMAL, "decimal");
    registerColumnType(Types.CHAR, "char");
    registerColumnType(Types.VARCHAR, "varchar");
    registerColumnType(Types.LONGVARCHAR, "longvarchar");
    registerColumnType(Types.DATE, "date");
    registerColumnType(Types.TIME, "time");
    registerColumnType(Types.TIMESTAMP, "timestamp");
    registerColumnType(Types.BINARY, "blob");
    registerColumnType(Types.VARBINARY, "blob");
    registerColumnType(Types.LONGVARBINARY, "blob");
    // registerColumnType(Types.NULL, "null");
    registerColumnType(Types.BLOB, "blob");
    registerColumnType(Types.CLOB, "clob");
    registerColumnType(Types.BOOLEAN, "integer");

    registerFunction("concat", new VarArgsSQLFunction(StringType.INSTANCE, "", "||", ""));
    registerFunction("mod", new SQLFunctionTemplate(StringType.INSTANCE, "?1 % ?2"));
    registerFunction("substr", new StandardSQLFunction("substr", StringType.INSTANCE));
    registerFunction("substring", new StandardSQLFunction("substr", StringType.INSTANCE));
}