Examples of JPQLQuery


Examples of com.mysema.query.jpa.JPQLQuery

    @Test
    public void One_To_One() {
        QEmployee employee = QEmployee.employee;
        QUser user = QUser.user;

        JPQLQuery query = query();
        query.from(employee);
        query.innerJoin(employee.user, user);
        query.list(employee);
    }
View Full Code Here

Examples of com.mysema.query.jpa.JPQLQuery

    @ExcludeIn(ORACLE)
    public void Substring2() {
        QCompany company = QCompany.company;
        StringExpression name = company.name;
        Integer companyId = query().from(company).singleResult(company.id);
        JPQLQuery query = query().from(company).where(company.id.eq(companyId));
        String str = query.singleResult(company.name);

        assertEquals(Integer.valueOf(29),
                query.singleResult(name.length().subtract(11)));

        assertEquals(str.substring(0, 7),
                query.singleResult(name.substring(0, 7)));

        assertEquals(str.substring(15),
                query.singleResult(name.substring(15)));

        assertEquals(str.substring(str.length()),
                query.singleResult(name.substring(name.length())));

        assertEquals(str.substring(str.length() - 11),
                query.singleResult(name.substring(name.length().subtract(11))));
    }
View Full Code Here

Examples of org.dayatang.domain.JpqlQuery

    private String jpql = "select o from Employee o";
   
    @Before
    public void setUp() {
        repository = mock(EntityRepository.class);
        instance = new JpqlQuery(repository, jpql);
    }
View Full Code Here

Examples of org.dayatang.domain.JpqlQuery

     * Test of createJpqlQuery method
     */
    @Test
    public void testCreateJpqlQuery() {
        String jpql = "select o from Dictionary o";
        JpqlQuery query = repository.createJpqlQuery(jpql);
        assertEquals(jpql, query.getJpql());
    }
View Full Code Here

Examples of org.dayatang.domain.JpqlQuery

     * Test of find method with JpqlQuery as parameter
     */
    @Test
    public void testJpqlQueryFindWithArrayParameters() {
        String queryString = "select o from  Dictionary o where o.category = ?";
        JpqlQuery query = new JpqlQuery(repository, queryString).setParameters(gender);
        List<Dictionary> results = repository.find(query);
        assertTrue(results.contains(male));
        assertFalse(results.contains(undergraduate));
    }
View Full Code Here

Examples of org.dayatang.domain.JpqlQuery

     * Test of find method with JpqlQuery as parameter
     */
    @Test
    public void testJpqlQueryFindWithMapParameters() {
        String queryString = "select o from  Dictionary o where o.category = :category";
        JpqlQuery query = new JpqlQuery(repository, queryString)
                .addParameter("category", gender);
        List<Dictionary> results = repository.find(query);
        assertTrue(results.contains(male));
        assertFalse(results.contains(undergraduate));
    }
View Full Code Here

Examples of org.dayatang.domain.JpqlQuery

     * Test of getSingleResult method with JpqlQuery as parameter
     */
    @Test
    public void testJpqlQueryGetSingleResult() {
        String queryString = "select o from  Dictionary o where o.category = :category and o.code = :code";
        JpqlQuery query = new JpqlQuery(repository, queryString)
                .addParameter("category", gender)
                .addParameter("code", "01");
        assertEquals(male, repository.getSingleResult(query));
    }
View Full Code Here

Examples of org.dayatang.domain.JpqlQuery

     * Test of getSingleResult method with JpqlQuery as parameter
     */
    @Test
    public void testJpqlQueryGetSingleResultCount() {
        String queryString = "select count(o) from  Dictionary o where o.category = :category and o.code = :code";
        JpqlQuery query = new JpqlQuery(repository, queryString)
                .addParameter("category", gender)
                .addParameter("code", "01");
        assertEquals(1L, repository.getSingleResult(query));
    }
View Full Code Here

Examples of org.dayatang.domain.JpqlQuery

     * Test of find method with JpqlQuery as parameter and scalar as result
     */
    @Test
    public void testJpqlQueryScalar() {
        String queryString = "select o.code, o.text from  Dictionary o where o.category = :category";
        JpqlQuery query = new JpqlQuery(repository, queryString)
                .addParameter("category", gender);
        List<Object[]> results = repository.find(query);
        for (Object[] row : results) {
            System.out.println(Arrays.toString(row));
        }
View Full Code Here

Examples of org.dayatang.domain.JpqlQuery

     */
    @Test
    public void testJpqlQueryExecuteUpdate() {
        String description = "abcd";
        String queryString = "update Dictionary set description = :description where category = :category";
        JpqlQuery query = new JpqlQuery(repository, queryString)
                .addParameter("description", description)
                .addParameter("category", gender);
        int count = repository.executeUpdate(query);
        assertTrue(count > 0);
        sessionFactory.getCurrentSession().clear();
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.