/**
 * Copyright (C) 2011  jtalks.org Team
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * Also add information on how to contact you by electronic and paper mail.
 * Creation date: Apr 12, 2011 / 8:05:19 PM
 * The jtalks.org Project
 */

package org.jtalks.antarcticle.model.dao.hibernate;

import org.jtalks.antarcticle.model.dao.ArticleCollectionDao;
import org.jtalks.antarcticle.model.entity.ArticleCollection;
import org.jtalks.common.model.dao.hibernate.AbstractHibernateDao;

import java.util.List;


/**
 * @author Vitaliy Kravchenko
 */
public class ArticleCollectionHibernateDao extends 
        AbstractHibernateDao<ArticleCollection> implements ArticleCollectionDao {

    /**
     * Gets all Article Collections
     *
     * @return  the List of Article Collections
     */
    @Override
    public List<ArticleCollection> getAll() {
        final String query =
                "SELECT ARTICLE_COLLECTION_ID, UUID, TITLE, DESCRIPTION, LAST_ARTICLE_ID " +
                "FROM (" +
                "    SELECT AC.ARTICLE_COLLECTION_ID, AC.UUID, AC.TITLE, AC.DESCRIPTION, AC.LAST_ARTICLE_ID, (" +
                "        SELECT max(creation_date) " +
                "        FROM article " +
                "        where article_collection_id = ac.article_collection_id) as CREATION_DATE " +
                "    FROM ARTICLE_COLLECTION AS AC) AS T " +
                "ORDER BY CREATION_DATE DESC";

        return getSession().createSQLQuery(query).addEntity(ArticleCollection.class).list();
    }
}

@@ -1544,631 +1544,49 @@
     
-final String query =%0A                %22SELECT ARTICLE_COLLECTION_ID, UUID, TITLE, DESCRIPTION, LAST_ARTICLE_ID %22 +%0A                %22FROM (%22 +%0A                %22    SELECT AC.ARTICLE_COLLECTION_ID, AC.UUID, AC.TITLE, AC.DESCRIPTION, AC.LAST_ARTICLE_ID, (%22 +%0A                %22        SELECT max(creation_date) %22 +%0A                %22        FROM article %22 +%0A                %22        where article_collection_id = ac.article_collection_id) as CREATION_DATE %22 +%0A                %22    FROM ARTICLE_COLLECTION AS AC) AS T %22 +%0A                %22ORDER BY CREATION_DATE DESC%22;%0A%0A        return getSession().createSQLQuery(query).addEntity(
+return getSession().getNamedQuery(%22getAll
 Arti
@@ -1602,14 +1602,10 @@
 tion
-.clas
 s
+%22
 ).li

Rollback named query (cherry picked from commit 076e5f7a472235c8712a21feaa5738155bcda93e)