use of com.liferay.portal.kernel.dao.orm.DynamicQuery in project liferay-blade-samples by liferay.
the class FooPersistenceTest method testDynamicQueryByProjectionExisting.
@Test
public void testDynamicQueryByProjectionExisting() throws Exception {
Foo newFoo = addFoo();
DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Foo.class, _dynamicQueryClassLoader);
dynamicQuery.setProjection(ProjectionFactoryUtil.property("fooId"));
Object newFooId = newFoo.getFooId();
dynamicQuery.add(RestrictionsFactoryUtil.in("fooId", new Object[] { newFooId }));
List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery);
Assert.assertEquals(1, result.size());
Object existingFooId = result.get(0);
Assert.assertEquals(existingFooId, newFooId);
}
use of com.liferay.portal.kernel.dao.orm.DynamicQuery in project liferay-blade-samples by liferay.
the class FooPersistenceTest method testDynamicQueryByProjectionMissing.
@Test
public void testDynamicQueryByProjectionMissing() throws Exception {
DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Foo.class, _dynamicQueryClassLoader);
dynamicQuery.setProjection(ProjectionFactoryUtil.property("fooId"));
dynamicQuery.add(RestrictionsFactoryUtil.in("fooId", new Object[] { RandomTestUtil.nextLong() }));
List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery);
Assert.assertEquals(0, result.size());
}
use of com.liferay.portal.kernel.dao.orm.DynamicQuery in project liferay-blade-samples by liferay.
the class FooPersistenceTest method testDynamicQueryByPrimaryKeyMissing.
@Test
public void testDynamicQueryByPrimaryKeyMissing() throws Exception {
DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Foo.class, _dynamicQueryClassLoader);
dynamicQuery.add(RestrictionsFactoryUtil.eq("fooId", RandomTestUtil.nextLong()));
List<Foo> result = _persistence.findWithDynamicQuery(dynamicQuery);
Assert.assertEquals(0, result.size());
}
use of com.liferay.portal.kernel.dao.orm.DynamicQuery 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);
}
use of com.liferay.portal.kernel.dao.orm.DynamicQuery 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);
}
Aggregations