Hibernate ORM Criteria - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Hibernate ORM Criteria class.

This code example shows how to use the following methods: add, createAlias, setProjection, setResultTransformer
    } 
     
    /** 
     * Test. 
     */ 
    @Test 
    public void testGetCriteria() 
    { 
        context.checking(new Expectations() 
        { 
            { 
                oneOf(hibernateSession).createCriteria(DomainGroup.class); 
            } 
        }); 
 
        Criteria result = sut.getCriteria(hibernateSession); 
        assertNotNull(result); 
         
        context.assertIsSatisfied(); 
    } 
} 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: add, createAlias, setProjection, setResultTransformer
        fields.add(getColumn("stickyActivityId"));
        fields.add(Projections.property("cb.accountId").as("personCreatedByAccountId"));
        fields.add(Projections.property("cb.displayName").as("personCreatedByDisplayName"));
        fields.add(Projections.property("cb.companyName").as("personCreatedByCompanyName"));
        fields.add(Projections.property("stream.id").as("streamId"));
        criteria.setProjection(fields);
        criteria.createAlias("createdBy", "cb");
        criteria.createAlias("streamScope", "stream");
 
        // We don't currently cache pending groups 
        // TODO: this needs to change - we should figure out how to remove this rule 
        criteria.add(Restrictions.eq("isPending", false));
 
        ModelViewResultTransformer<DomainGroupModelView> resultTransformer = //
        new ModelViewResultTransformer<DomainGroupModelView>(new DomainGroupModelViewFactory()); 
        criteria.setResultTransformer(resultTransformer);
 
        return criteria;
    } 
 
    /** 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: list, setFirstResult, setMaxResults, setProjection, setResultTransformer
		return list;
	} 
	 
	@Override 
	public ListPart<T> listPart(Long firstResult, Long maxResults) {
		criteria.setProjection(null);
		criteria.setResultTransformer(Criteria.ROOT_ENTITY);
		 
		if (firstResult != null) {
			criteria.setFirstResult(firstResult.intValue());
		} 
		 
		if (maxResults != null) {
			criteria.setMaxResults(maxResults.intValue());
		} 
		 
		@SuppressWarnings("unchecked") 
		List<T> list = criteria.list();
		 
		return ListPart.newListPart(list, firstResult, maxResults, null, null);

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: createAlias, setProjection, setResultTransformer
            } 
        }); 
 
        Criteria result = sut.getCriteria(hibernateSession); 
        assertNotNull(result); 
 
        context.assertIsSatisfied(); 
    } 
} 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: list, setFirstResult, setMaxResults, setProjection, setResultTransformer
		} catch (Exception e) {
			throw new RuntimeException(
					"cannot read/write 'orderEntries' from CriteriaImpl", e);
		} 
 
		int totalCount = ((Number) crit.setProjection(Projections.rowCount())
				.uniqueResult()).intValue();
		Pagination p = new Pagination(pageNo, pageSize, totalCount);
		if (totalCount < 1) {
			p.setList(new ArrayList());
			return p;
		} 
 
		// 将之前的Projection,ResultTransformer和OrderBy条件重新设回去 
		crit.setProjection(projection);
		if (projection == null) {
			crit.setResultTransformer(CriteriaSpecification.ROOT_ENTITY);
		} 
		if (transformer != null) {
			crit.setResultTransformer(transformer);

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
See Code Examples for Hibernate ORM Criteria Methods: