001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.bookmarks.service.persistence;
016    
017    import com.liferay.portal.kernel.dao.orm.QueryPos;
018    import com.liferay.portal.kernel.dao.orm.SQLQuery;
019    import com.liferay.portal.kernel.dao.orm.Session;
020    import com.liferay.portal.kernel.exception.SystemException;
021    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
022    import com.liferay.portlet.bookmarks.model.BookmarksFolder;
023    import com.liferay.portlet.bookmarks.model.impl.BookmarksFolderImpl;
024    import com.liferay.util.dao.orm.CustomSQLUtil;
025    
026    import java.util.List;
027    
028    /**
029     * @author Joshua Steven Rodriguez
030     */
031    public class BookmarksFolderFinderImpl
032            extends BasePersistenceImpl<BookmarksFolder>
033            implements BookmarksFolderFinder {
034    
035            public static final String FIND_BY_NO_RESOURCE_BLOCKS =
036                    BookmarksFolderFinder.class.getName() + ".findByNoResourceBlocks";
037    
038            @Override
039            public List<BookmarksFolder> findByNoResourceBlocks()
040                    throws SystemException {
041    
042                    Session session = null;
043    
044                    try {
045                            session = openSession();
046    
047                            String sql = CustomSQLUtil.get(FIND_BY_NO_RESOURCE_BLOCKS);
048    
049                            SQLQuery q = session.createSQLQuery(sql);
050    
051                            q.addEntity("BookmarksFolder", BookmarksFolderImpl.class);
052    
053                            QueryPos qPos = QueryPos.getInstance(q);
054    
055                            qPos.add(BookmarksFolder.class.getName());
056    
057                            return q.list(true);
058                    }
059                    catch (Exception e) {
060                            throw new SystemException(e);
061                    }
062                    finally {
063                            closeSession(session);
064                    }
065            }
066    
067    }