Package javax.persistence.criteria

Examples of javax.persistence.criteria.CriteriaBuilder.array()


    em = factory.createEntityManager();
    em.getTransaction().begin();
    final CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<Object[]> q = cb.createQuery(Object[].class);
    Root<Customer> c = q.from(Customer.class);
    q.select( cb.array( c.get(Customer_.name), c.get(Customer_.age) ) );
    List<Object[]> result = em.createQuery(q).getResultList();
    assertEquals( 1, result.size() );
    assertEquals( c1.getName(), result.get( 0 )[0] );
    assertEquals( c1.getAge(), result.get( 0 )[1] );
    em.getTransaction().commit();
View Full Code Here


    @Override
    public Map<Integer, MetadataSourceInfo> findAllSourceInfo(Specification<Metadata> spec) {
        CriteriaBuilder cb = _entityManager.getCriteriaBuilder();
        CriteriaQuery<Object[]> cbQuery = cb.createQuery(Object[].class);
        Root<Metadata> root = cbQuery.from(Metadata.class);
        cbQuery.select(cb.array(root.get(Metadata_.id), root.get(Metadata_.sourceInfo)));

        cbQuery.where(spec.toPredicate(root, cbQuery, cb));
        Map<Integer, MetadataSourceInfo> results = Maps.newHashMap();
        final List<Object[]> resultList = _entityManager.createQuery(cbQuery).getResultList();
        for (Object[] objects : resultList) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.