001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.bookmarks.service.persistence;
016    
017    import com.liferay.portal.kernel.dao.orm.SQLQuery;
018    import com.liferay.portal.kernel.dao.orm.Session;
019    import com.liferay.portal.kernel.exception.SystemException;
020    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
021    import com.liferay.portlet.bookmarks.model.BookmarksEntry;
022    import com.liferay.portlet.bookmarks.model.impl.BookmarksEntryImpl;
023    import com.liferay.util.dao.orm.CustomSQLUtil;
024    
025    import java.util.List;
026    
027    /**
028     * @author Brian Wing Shun Chan
029     */
030    public class BookmarksEntryFinderImpl
031            extends BasePersistenceImpl<BookmarksEntry>
032            implements BookmarksEntryFinder {
033    
034            public static final String FIND_BY_NO_ASSETS =
035                    BookmarksEntryFinder.class.getName() + ".findByNoAssets";
036    
037            @Override
038            public List<BookmarksEntry> findByNoAssets() throws SystemException {
039                    Session session = null;
040    
041                    try {
042                            session = openSession();
043    
044                            String sql = CustomSQLUtil.get(FIND_BY_NO_ASSETS);
045    
046                            SQLQuery q = session.createSQLQuery(sql);
047    
048                            q.addEntity("BookmarksEntry", BookmarksEntryImpl.class);
049    
050                            return q.list(true);
051                    }
052                    catch (Exception e) {
053                            throw new SystemException(e);
054                    }
055                    finally {
056                            closeSession(session);
057                    }
058            }
059    
060    }