use of com.liferay.roster.model.Club in project liferay-ide by liferay.
the class ClubPersistenceImpl method findByUuid_PrevAndNext.
/**
* Returns the clubs before and after the current club in the ordered set where uuid = ?.
*
* @param clubId the primary key of the current club
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
* @return the previous, current, and next club
* @throws NoSuchClubException if a club with the primary key could not be found
*/
@Override
public Club[] findByUuid_PrevAndNext(long clubId, String uuid, OrderByComparator<Club> orderByComparator) throws NoSuchClubException {
Club club = findByPrimaryKey(clubId);
Session session = null;
try {
session = openSession();
Club[] array = new ClubImpl[3];
array[0] = getByUuid_PrevAndNext(session, club, uuid, orderByComparator, true);
array[1] = club;
array[2] = getByUuid_PrevAndNext(session, club, uuid, orderByComparator, false);
return array;
} catch (Exception e) {
throw processException(e);
} finally {
closeSession(session);
}
}
use of com.liferay.roster.model.Club in project liferay-ide by liferay.
the class ClubPersistenceImpl method fetchByPrimaryKeys.
@Override
public Map<Serializable, Club> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
if (primaryKeys.isEmpty()) {
return Collections.emptyMap();
}
Map<Serializable, Club> map = new HashMap<Serializable, Club>();
if (primaryKeys.size() == 1) {
Iterator<Serializable> iterator = primaryKeys.iterator();
Serializable primaryKey = iterator.next();
Club club = fetchByPrimaryKey(primaryKey);
if (club != null) {
map.put(primaryKey, club);
}
return map;
}
Set<Serializable> uncachedPrimaryKeys = null;
for (Serializable primaryKey : primaryKeys) {
Club club = (Club) entityCache.getResult(ClubModelImpl.ENTITY_CACHE_ENABLED, ClubImpl.class, primaryKey);
if (club == null) {
if (uncachedPrimaryKeys == null) {
uncachedPrimaryKeys = new HashSet<Serializable>();
}
uncachedPrimaryKeys.add(primaryKey);
} else {
map.put(primaryKey, club);
}
}
if (uncachedPrimaryKeys == null) {
return map;
}
StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);
query.append(_SQL_SELECT_CLUB_WHERE_PKS_IN);
for (Serializable primaryKey : uncachedPrimaryKeys) {
query.append(String.valueOf(primaryKey));
query.append(StringPool.COMMA);
}
query.setIndex(query.index() - 1);
query.append(StringPool.CLOSE_PARENTHESIS);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
for (Club club : (List<Club>) q.list()) {
map.put(club.getPrimaryKeyObj(), club);
cacheResult(club);
uncachedPrimaryKeys.remove(club.getPrimaryKeyObj());
}
for (Serializable primaryKey : uncachedPrimaryKeys) {
entityCache.putResult(ClubModelImpl.ENTITY_CACHE_ENABLED, ClubImpl.class, primaryKey, _nullClub);
}
} catch (Exception e) {
throw processException(e);
} finally {
closeSession(session);
}
return map;
}
use of com.liferay.roster.model.Club in project liferay-ide by liferay.
the class ClubPersistenceImpl method clearCache.
@Override
public void clearCache(List<Club> clubs) {
finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
for (Club club : clubs) {
entityCache.removeResult(ClubModelImpl.ENTITY_CACHE_ENABLED, ClubImpl.class, club.getPrimaryKey());
}
}
use of com.liferay.roster.model.Club in project liferay-ide by liferay.
the class ClubPersistenceTest method testFetchByPrimaryKeyExisting.
@Test
public void testFetchByPrimaryKeyExisting() throws Exception {
Club newClub = addClub();
Club existingClub = _persistence.fetchByPrimaryKey(newClub.getPrimaryKey());
Assert.assertEquals(existingClub, newClub);
}
use of com.liferay.roster.model.Club in project liferay-ide by liferay.
the class ClubPersistenceTest method testDynamicQueryByProjectionExisting.
@Test
public void testDynamicQueryByProjectionExisting() throws Exception {
Club newClub = addClub();
DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Club.class, _dynamicQueryClassLoader);
dynamicQuery.setProjection(ProjectionFactoryUtil.property("clubId"));
Object newClubId = newClub.getClubId();
dynamicQuery.add(RestrictionsFactoryUtil.in("clubId", new Object[] { newClubId }));
List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery);
Assert.assertEquals(1, result.size());
Object existingClubId = result.get(0);
Assert.assertEquals(existingClubId, newClubId);
}
Aggregations