Search in sources :

Example 21 with Club

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;
}
Also used : Club(com.liferay.roster.model.Club)

Example 22 with 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()));
}
Also used : Serializable(java.io.Serializable) Club(com.liferay.roster.model.Club) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 23 with Club

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);
}
Also used : Club(com.liferay.roster.model.Club) DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) Test(org.junit.Test)

Example 24 with Club

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());
}
Also used : DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) Club(com.liferay.roster.model.Club) Test(org.junit.Test)

Example 25 with Club

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;
}
Also used : Club(com.liferay.roster.model.Club) ClubImpl(com.liferay.roster.model.impl.ClubImpl) NoSuchClubException(com.liferay.roster.exception.NoSuchClubException) Session(com.liferay.portal.kernel.dao.orm.Session)

Aggregations

Club (com.liferay.roster.model.Club)27 Test (org.junit.Test)13 NoSuchClubException (com.liferay.roster.exception.NoSuchClubException)8 Session (com.liferay.portal.kernel.dao.orm.Session)6 StringBundler (com.liferay.portal.kernel.util.StringBundler)6 ClubImpl (com.liferay.roster.model.impl.ClubImpl)5 ActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)4 Query (com.liferay.portal.kernel.dao.orm.Query)4 Serializable (java.io.Serializable)4 DynamicQuery (com.liferay.portal.kernel.dao.orm.DynamicQuery)3 HashSet (java.util.HashSet)3 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)2 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)2 IntegerWrapper (com.liferay.portal.kernel.util.IntegerWrapper)1 HashMap (java.util.HashMap)1 List (java.util.List)1