Package org.dayatang.domain

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


     * 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

     * 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

     * 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

     * 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

     * 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

     * 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

     */
    @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

        return results.isEmpty() ? null : results.get(0);
    }

    @Override
    public JpqlQuery createJpqlQuery(String jpql) {
        return new JpqlQuery(this, jpql);
    }
View Full Code Here

    private final JpqlQuery query;

    public ChannelJpqlQuery(EntityRepository repository, String jpql) {
        super(repository);
        Assert.notBlank(jpql, "JPQL must be set!");
        query = new JpqlQuery(repository, jpql);
        setQuery(query);
    }
View Full Code Here

TOP

Related Classes of org.dayatang.domain.JpqlQuery

Copyright © 2018 www.massapicom. 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.