use of com.liferay.portal.kernel.dao.orm.Session in project liferay-ide by liferay.
the class ArtistPersistenceImpl method filterFindByU_G_PrevAndNext.
/**
* Returns the artists before and after the current artist in the ordered set of artists that the user has permission to view where userId = ? and groupId = ?.
*
* @param artistId the primary key of the current artist
* @param userId the user ID
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
* @return the previous, current, and next artist
* @throws org.liferay.jukebox.NoSuchArtistException if a artist with the primary key could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public Artist[] filterFindByU_G_PrevAndNext(long artistId, long userId, long groupId, OrderByComparator orderByComparator) throws NoSuchArtistException, SystemException {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByU_G_PrevAndNext(artistId, userId, groupId, orderByComparator);
}
Artist artist = findByPrimaryKey(artistId);
Session session = null;
try {
session = openSession();
Artist[] array = new ArtistImpl[3];
array[0] = filterGetByU_G_PrevAndNext(session, artist, userId, groupId, orderByComparator, true);
array[1] = artist;
array[2] = filterGetByU_G_PrevAndNext(session, artist, userId, groupId, orderByComparator, false);
return array;
} catch (Exception e) {
throw processException(e);
} finally {
closeSession(session);
}
}
use of com.liferay.portal.kernel.dao.orm.Session in project liferay-ide by liferay.
the class ArtistPersistenceImpl method removeImpl.
@Override
protected Artist removeImpl(Artist artist) throws SystemException {
artist = toUnwrappedModel(artist);
Session session = null;
try {
session = openSession();
if (!session.contains(artist)) {
artist = (Artist) session.get(ArtistImpl.class, artist.getPrimaryKeyObj());
}
if (artist != null) {
session.delete(artist);
}
} catch (Exception e) {
throw processException(e);
} finally {
closeSession(session);
}
if (artist != null) {
clearCache(artist);
}
return artist;
}
use of com.liferay.portal.kernel.dao.orm.Session in project liferay-ide by liferay.
the class ArtistPersistenceImpl method findByG_S_PrevAndNext.
/**
* Returns the artists before and after the current artist in the ordered set where groupId = ? and status = ?.
*
* @param artistId the primary key of the current artist
* @param groupId the group ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
* @return the previous, current, and next artist
* @throws org.liferay.jukebox.NoSuchArtistException if a artist with the primary key could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public Artist[] findByG_S_PrevAndNext(long artistId, long groupId, int status, OrderByComparator orderByComparator) throws NoSuchArtistException, SystemException {
Artist artist = findByPrimaryKey(artistId);
Session session = null;
try {
session = openSession();
Artist[] array = new ArtistImpl[3];
array[0] = getByG_S_PrevAndNext(session, artist, groupId, status, orderByComparator, true);
array[1] = artist;
array[2] = getByG_S_PrevAndNext(session, artist, groupId, status, orderByComparator, false);
return array;
} catch (Exception e) {
throw processException(e);
} finally {
closeSession(session);
}
}
use of com.liferay.portal.kernel.dao.orm.Session in project liferay-ide by liferay.
the class ArtistPersistenceImpl method findAll.
/**
* Returns an ordered range of all the artists.
*
* <p>
* Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link org.liferay.jukebox.model.impl.ArtistModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
* </p>
*
* @param start the lower bound of the range of artists
* @param end the upper bound of the range of artists (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
* @return the ordered range of artists
* @throws SystemException if a system exception occurred
*/
@Override
public List<Artist> findAll(int start, int end, OrderByComparator orderByComparator) throws SystemException {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
pagination = false;
finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
finderArgs = FINDER_ARGS_EMPTY;
} else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
finderArgs = new Object[] { start, end, orderByComparator };
}
List<Artist> list = (List<Artist>) FinderCacheUtil.getResult(finderPath, finderArgs, this);
if (list == null) {
StringBundler query = null;
String sql = null;
if (orderByComparator != null) {
query = new StringBundler(2 + (orderByComparator.getOrderByFields().length * 3));
query.append(_SQL_SELECT_ARTIST);
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
sql = query.toString();
} else {
sql = _SQL_SELECT_ARTIST;
if (pagination) {
sql = sql.concat(ArtistModelImpl.ORDER_BY_JPQL);
}
}
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
if (!pagination) {
list = (List<Artist>) QueryUtil.list(q, getDialect(), start, end, false);
Collections.sort(list);
list = new UnmodifiableList<Artist>(list);
} else {
list = (List<Artist>) QueryUtil.list(q, getDialect(), start, end);
}
cacheResult(list);
FinderCacheUtil.putResult(finderPath, finderArgs, list);
} catch (Exception e) {
FinderCacheUtil.removeResult(finderPath, finderArgs);
throw processException(e);
} finally {
closeSession(session);
}
}
return list;
}
use of com.liferay.portal.kernel.dao.orm.Session in project liferay-ide by liferay.
the class ArtistPersistenceImpl method findByCompanyId_PrevAndNext.
/**
* Returns the artists before and after the current artist in the ordered set where companyId = ?.
*
* @param artistId the primary key of the current artist
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
* @return the previous, current, and next artist
* @throws org.liferay.jukebox.NoSuchArtistException if a artist with the primary key could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public Artist[] findByCompanyId_PrevAndNext(long artistId, long companyId, OrderByComparator orderByComparator) throws NoSuchArtistException, SystemException {
Artist artist = findByPrimaryKey(artistId);
Session session = null;
try {
session = openSession();
Artist[] array = new ArtistImpl[3];
array[0] = getByCompanyId_PrevAndNext(session, artist, companyId, orderByComparator, true);
array[1] = artist;
array[2] = getByCompanyId_PrevAndNext(session, artist, companyId, orderByComparator, false);
return array;
} catch (Exception e) {
throw processException(e);
} finally {
closeSession(session);
}
}
Aggregations