use of com.liferay.roster.model.Club in project liferay-ide by liferay.
the class ClubPersistenceTest method addClub.
protected Club addClub() throws Exception {
long pk = RandomTestUtil.nextLong();
Club club = _persistence.create(pk);
club.setUuid(RandomTestUtil.randomString());
club.setCreateDate(RandomTestUtil.nextDate());
club.setModifiedDate(RandomTestUtil.nextDate());
club.setName(RandomTestUtil.randomString());
_clubs.add(_persistence.update(club));
return club;
}
use of com.liferay.roster.model.Club in project liferay-ide by liferay.
the class ClubPersistenceTest method testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist.
@Test
public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist() throws Exception {
Club newClub1 = addClub();
Club newClub2 = addClub();
Set<Serializable> primaryKeys = new HashSet<Serializable>();
primaryKeys.add(newClub1.getPrimaryKey());
primaryKeys.add(newClub2.getPrimaryKey());
Map<Serializable, Club> clubs = _persistence.fetchByPrimaryKeys(primaryKeys);
Assert.assertEquals(2, clubs.size());
Assert.assertEquals(newClub1, clubs.get(newClub1.getPrimaryKey()));
Assert.assertEquals(newClub2, clubs.get(newClub2.getPrimaryKey()));
}
use of com.liferay.roster.model.Club in project liferay-ide by liferay.
the class ClubPersistenceTest method testDynamicQueryByPrimaryKeyExisting.
@Test
public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
Club newClub = addClub();
DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Club.class, _dynamicQueryClassLoader);
dynamicQuery.add(RestrictionsFactoryUtil.eq("clubId", newClub.getClubId()));
List<Club> result = _persistence.findWithDynamicQuery(dynamicQuery);
Assert.assertEquals(1, result.size());
Club existingClub = result.get(0);
Assert.assertEquals(existingClub, newClub);
}
use of com.liferay.roster.model.Club in project liferay-ide by liferay.
the class ClubPersistenceTest method testDynamicQueryByPrimaryKeyMissing.
@Test
public void testDynamicQueryByPrimaryKeyMissing() throws Exception {
DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Club.class, _dynamicQueryClassLoader);
dynamicQuery.add(RestrictionsFactoryUtil.eq("clubId", RandomTestUtil.nextLong()));
List<Club> result = _persistence.findWithDynamicQuery(dynamicQuery);
Assert.assertEquals(0, result.size());
}
use of com.liferay.roster.model.Club in project liferay-ide by liferay.
the class ClubPersistenceImpl method fetchByPrimaryKey.
/**
* Returns the club with the primary key or returns <code>null</code> if it could not be found.
*
* @param primaryKey the primary key of the club
* @return the club, or <code>null</code> if a club with the primary key could not be found
*/
@Override
public Club fetchByPrimaryKey(Serializable primaryKey) {
Club club = (Club) entityCache.getResult(ClubModelImpl.ENTITY_CACHE_ENABLED, ClubImpl.class, primaryKey);
if (club == _nullClub) {
return null;
}
if (club == null) {
Session session = null;
try {
session = openSession();
club = (Club) session.get(ClubImpl.class, primaryKey);
if (club != null) {
cacheResult(club);
} else {
entityCache.putResult(ClubModelImpl.ENTITY_CACHE_ENABLED, ClubImpl.class, primaryKey, _nullClub);
}
} catch (Exception e) {
entityCache.removeResult(ClubModelImpl.ENTITY_CACHE_ENABLED, ClubImpl.class, primaryKey);
throw processException(e);
} finally {
closeSession(session);
}
}
return club;
}
Aggregations