Example usage for org.hibernate.type LongType INSTANCE

List of usage examples for org.hibernate.type LongType INSTANCE

Introduction

In this page you can find the example usage for org.hibernate.type LongType INSTANCE.

Prototype

LongType INSTANCE

To view the source code for org.hibernate.type LongType INSTANCE.

Click Source Link

Usage

From source file:org.squashtest.tm.service.internal.repository.hibernate.HibernateUserDao.java

License:Open Source License

@Override
public int countAllTeamMembers(long teamId) {
    Query query = currentSession().getNamedQuery("user.countAllTeamMembers");
    query.setParameter("teamId", teamId, LongType.INSTANCE);
    return (Integer) query.uniqueResult();
}

From source file:org.squashtest.tm.service.internal.repository.hibernate.HibernateUserDao.java

License:Open Source License

@Override
public void unassignUserFromAllTestPlan(long userId) {
    Query query = currentSession().getNamedQuery("user.unassignFromAllCampaignTestPlan");
    query.setParameter("userId", userId, LongType.INSTANCE);
    query.executeUpdate();/*from w  w w  .j  a v  a  2s  . co  m*/

    query = currentSession().getNamedQuery("user.unassignFromAllIterationTestPlan");
    query.setParameter("userId", userId, LongType.INSTANCE);
    query.executeUpdate();
}

From source file:org.squashtest.tm.service.internal.repository.hibernate.ParameterDaoImpl.java

License:Open Source License

@Override
public List<Parameter> findAllParametersByTestCase(Long testcaseId) {

    List<Parameter> allParameters = new LinkedList<>();

    Set<Long> exploredTc = new HashSet<>();
    List<Long> srcTc = new LinkedList<>();
    List<Long> destTc;

    Query next = em.unwrap(Session.class).getNamedQuery("parameter.findTestCasesThatDelegatesParameters");

    srcTc.add(testcaseId);/*  w w w  . j  a  va2 s.  co  m*/

    while (!srcTc.isEmpty()) {

        allParameters.addAll(findTestCaseParameters(srcTc));

        next.setParameterList("srcIds", srcTc, LongType.INSTANCE);
        destTc = next.list();

        exploredTc.addAll(srcTc);
        srcTc = destTc;
        srcTc.removeAll(exploredTc);

    }

    return allParameters;

}

From source file:org.squashtest.tm.service.internal.repository.hibernate.RequirementVersionCoverageDaoImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/* w w  w  .j  av a 2 s .  c o m*/
public List<RequirementVersion> findDistinctRequirementVersionsByTestCases(Collection<Long> testCaseIds,
        PagingAndSorting pagingAndSorting) {

    if (testCaseIds.isEmpty()) {
        return Collections.emptyList();
    }

    // we have to fetch our query and modify the hql a bit, hence the weird operation below
    Query namedquery = currentSession()
            .getNamedQuery("RequirementVersion.findDistinctRequirementVersionsByTestCases");
    String hql = namedquery.getQueryString();
    hql = SortingUtils.addOrder(hql, pagingAndSorting);

    Query q = currentSession().createQuery(hql);
    if (!pagingAndSorting.shouldDisplayAll()) {
        PagingUtils.addPaging(q, pagingAndSorting);
    }

    q.setParameterList("testCaseIds", testCaseIds, LongType.INSTANCE);

    List<Object[]> raw = q.list();

    // now we have to collect from the result set the only thing
    // we want : the RequirementVersions
    List<RequirementVersion> res = new ArrayList<>(raw.size());
    for (Object[] tuple : raw) {
        res.add((RequirementVersion) tuple[0]);
    }
    if ("endDate".equals(pagingAndSorting.getSortedAttribute())) {
        Collections.sort(res, new Comparator<RequirementVersion>() {
            @Override
            public int compare(RequirementVersion req1, RequirementVersion req2) {
                return compareReqMilestoneDate(req1, req2);
            }
        });

        if (pagingAndSorting.getSortOrder() == SortOrder.ASCENDING) {
            Collections.reverse(res);
        }
    }
    return res;

}

From source file:org.squashtest.tm.service.internal.repository.hibernate.TestCaseDaoImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
private List<NamedReference> findTestCaseDetails(Collection<Long> ids) {
    if (ids.isEmpty()) {
        return Collections.emptyList();
    }/*  w w  w  . j a  va2s  .  co  m*/
    Query q = currentSession().getNamedQuery("testCase.findTestCaseDetails");
    q.setParameterList(TEST_CASE_IDS_PARAM_NAME, ids, LongType.INSTANCE);
    return q.list();
}

From source file:org.squashtest.tm.service.internal.repository.hibernate.TestCaseDaoImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override//from   w  w  w  .j  ava2s  .  c  om
public List<Long> findAllTestCaseIdsByNodeIds(Collection<Long> nodeIds) {
    if (nodeIds.isEmpty()) {
        return Collections.emptyList();
    }

    Query query = currentSession().createSQLQuery(FIND_ALL_DESCENDANT_TESTCASE_QUERY);
    query.setParameterList("nodeIds", nodeIds, LongType.INSTANCE);
    query.setResultTransformer(new SqLIdResultTransformer());

    return query.list();
}

From source file:org.squashtest.tm.service.internal.testcase.TestCaseStatisticsServiceImpl.java

License:Open Source License

@Override
public TestCaseBoundRequirementsStatistics gatherBoundRequirementStatistics(Collection<Long> testCaseIds) {

    if (testCaseIds.isEmpty()) {
        return new TestCaseBoundRequirementsStatistics();
    }//from  w  ww .  j a  va 2s .c o m

    Query query = em.unwrap(Session.class).createSQLQuery(SQL_BOUND_REQS_STATISTICS);
    query.setParameterList("testCaseIds", testCaseIds, LongType.INSTANCE);

    List<Object[]> tuples = query.list();

    TestCaseBoundRequirementsStatistics stats = new TestCaseBoundRequirementsStatistics();

    Integer sizeClass;
    Integer count;
    for (Object[] tuple : tuples) {

        sizeClass = (Integer) tuple[0];
        count = ((BigInteger) tuple[1]).intValue();

        switch (sizeClass) {
        case 0:
            stats.setZeroRequirements(count);
            break;
        case 1:
            stats.setOneRequirement(count);
            break;
        case 2:
            stats.setManyRequirements(count);
            break;
        default:
            throw new IllegalArgumentException(
                    "TestCaseStatisticsServiceImpl#gatherBoundRequirementStatistics : "
                            + "there should not be a sizeclass <0 or >2. It's a bug.");

        }
    }

    return stats;

}

From source file:org.squashtest.tm.service.internal.testcase.TestCaseStatisticsServiceImpl.java

License:Open Source License

@Override
public TestCaseSizeStatistics gatherTestCaseSizeStatistics(Collection<Long> testCaseIds) {

    if (testCaseIds.isEmpty()) {
        return new TestCaseSizeStatistics();
    }//from w w  w  .j a v  a  2  s  .  c o m

    Query query = em.unwrap(Session.class).createSQLQuery(SQL_SIZE_STATISTICS);
    query.setParameterList("testCaseIds", testCaseIds, LongType.INSTANCE);

    List<Object[]> tuples = query.list();

    TestCaseSizeStatistics stats = new TestCaseSizeStatistics();

    Integer sizeClass;
    Integer count;
    for (Object[] tuple : tuples) {

        sizeClass = (Integer) tuple[0];
        count = ((BigInteger) tuple[1]).intValue();

        switch (sizeClass) {
        case 0:
            stats.setZeroSteps(count);
            break;
        case 1:
            stats.setBetween0And10Steps(count);
            break;
        case 2:
            stats.setBetween11And20Steps(count);
            break;
        case 3:
            stats.setAbove20Steps(count);
            break;
        default:
            throw new IllegalArgumentException("TestCaseStatisticsServiceImpl#gatherTestCaseSizeStatistics : "
                    + "there should not be a sizeclass <0 or >3. It's a bug.");

        }
    }

    return stats;
}

From source file:org.squashtest.tm.service.security.acls.jdbc.DerivedPermissionsManager.java

License:Open Source License

private boolean doesExist(ObjectIdentity identity) {

    Query query = em.unwrap(Session.class).createSQLQuery(CHECK_OBJECT_IDENTITY_EXISTENCE);
    query.setParameter("id", identity.getIdentifier(), LongType.INSTANCE);
    query.setParameter("class", identity.getType());

    List<?> result = query.list();
    return !result.isEmpty();
}

From source file:org.squashtest.tm.service.security.acls.jdbc.DerivedPermissionsManager.java

License:Open Source License

private boolean doesExist(long partyId) {

    Query query = em.unwrap(Session.class).createSQLQuery(CHECK_PARTY_EXISTENCE);
    query.setParameter("id", partyId, LongType.INSTANCE);

    List<?> result = query.list();
    return !result.isEmpty();
}