001    /**
002     * Copyright (c) 2000-present 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.impl;
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.portlet.bookmarks.service.persistence.BookmarksEntryFinder;
024    import com.liferay.util.dao.orm.CustomSQLUtil;
025    
026    import java.util.List;
027    
028    /**
029     * @author Brian Wing Shun Chan
030     */
031    public class BookmarksEntryFinderImpl
032            extends BasePersistenceImpl<BookmarksEntry>
033            implements BookmarksEntryFinder {
034    
035            public static final String FIND_BY_NO_ASSETS =
036                    BookmarksEntryFinder.class.getName() + ".findByNoAssets";
037    
038            @Override
039            public List<BookmarksEntry> findByNoAssets() {
040                    Session session = null;
041    
042                    try {
043                            session = openSession();
044    
045                            String sql = CustomSQLUtil.get(FIND_BY_NO_ASSETS);
046    
047                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
048    
049                            q.addEntity("BookmarksEntry", BookmarksEntryImpl.class);
050    
051                            return q.list(true);
052                    }
053                    catch (Exception e) {
054                            throw new SystemException(e);
055                    }
056                    finally {
057                            closeSession(session);
058                    }
059            }
060    
061    }