Package org.dayatang.domain

Examples of org.dayatang.domain.SqlQuery


     * Test of createSqlQuery method
     */
    @Test
    public void testCreateSqlQuery() {
        String sql = "select * from dictionaries";
        SqlQuery query = repository.createSqlQuery(sql);
        assertEquals(sql, query.getSql());
    }
View Full Code Here


     * Test of find method with SqlQuery as parameter
     */
    @Test
    public void testSqlQueryFindWithArrayParameters() {
        String sql = "select * from dictionaries as o where o.is_disabled = ? and o.category_id = ? order by o.sort_order";
        SqlQuery query = new SqlQuery(repository, sql)
                .setParameters(false, gender.getId())
                .setResultEntityClass(Dictionary.class);
        List<Dictionary> results = repository.find(query);
        assertTrue(results.contains(male));
        assertFalse(results.contains(undergraduate));
View Full Code Here

     */
    @Test
    public void testSqlQueryFindWithMapParameters() {
        String sql = "select * from dictionaries as o where o.is_disabled = :disabled "
                + "and o.category_id = :categoryId order by o.sort_order";
        SqlQuery query = new SqlQuery(repository, sql)
                .addParameter("categoryId", gender.getId())
                .addParameter("disabled", false)
                .setResultEntityClass(Dictionary.class);
        List<Dictionary> results = repository.find(query);
        assertTrue(results.contains(male));
View Full Code Here

     */
    @Test
    public void testSqlQueryGetSingleResult() {
        String sql = "select * from dictionaries as o where o.is_disabled = ? "
                + "and o.category_id = ? and o.code = ?";
        SqlQuery query = new SqlQuery(repository, sql)
                .setParameters(false, gender.getId(), "01")
                .setResultEntityClass(Dictionary.class);
        assertEquals(male, repository.getSingleResult(query));
    }
View Full Code Here

     * Test of getSingleResult method with JpqlQuery as parameter
     */
    @Test
    public void testSqlQueryGetSingleResultCount() {
        String queryString = "select count(*) from  categories o where o.name = :name";
        SqlQuery query = new SqlQuery(repository, queryString)
                .addParameter("name", "gender");
        assertEquals(1, ((Number)repository.getSingleResult(query)).longValue());
    }
View Full Code Here

     * Test of find method with SqlQuery as parameter and scalar as result
     */
    @Test
    public void testSqlQueryScalar() {
        String sql = "select o.code, o.text from  dictionaries o where o.category_id = :category";
        SqlQuery query = new SqlQuery(repository, sql)
                .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 testSqlQueryExecuteUpdate() {
        String description = "abcd";
        String sql = "update dictionaries set description = :description where category_id = :categoryId";
        SqlQuery query = new SqlQuery(repository, sql)
                .addParameter("description", description)
                .addParameter("categoryId", gender.getId());
        int count = repository.executeUpdate(query);
        assertTrue(count > 0);
        sessionFactory.getCurrentSession().clear();
View Full Code Here

        return query;
    }

    @Override
    public SqlQuery createSqlQuery(String sql) {
        return new SqlQuery(this, sql);
    }
View Full Code Here

    private final SqlQuery query;

    public ChannelSqlQuery(EntityRepository repository, String sql) {
        super(repository);
        Assert.notBlank(sql, "SQL must be set!");
        query = new SqlQuery(repository, sql);
        setQuery(query);
    }
View Full Code Here

     * Test of createSqlQuery method
     */
    @Test
    public void testCreateSqlQuery() {
        String sql = "select * from dictionaries";
        SqlQuery query = repository.createSqlQuery(sql);
        assertEquals(sql, query.getSql());
    }
View Full Code Here

TOP

Related Classes of org.dayatang.domain.SqlQuery

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.