Search in sources :

Example 11 with DynamicQuery

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

Example 12 with DynamicQuery

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

Example 13 with DynamicQuery

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

Example 14 with DynamicQuery

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);
}
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 15 with DynamicQuery

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);
}
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)

Aggregations

DynamicQuery (com.liferay.portal.kernel.dao.orm.DynamicQuery)23 ActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)21 Test (org.junit.Test)16 Foo (com.liferay.blade.samples.servicebuilder.model.Foo)4 Property (com.liferay.portal.kernel.dao.orm.Property)3 Document (com.liferay.portal.kernel.search.Document)3 Club (com.liferay.roster.model.Club)3 Roster (com.liferay.roster.model.Roster)3 RosterMember (com.liferay.roster.model.RosterMember)3 Conjunction (com.liferay.portal.kernel.dao.orm.Conjunction)2 Criterion (com.liferay.portal.kernel.dao.orm.Criterion)2 Disjunction (com.liferay.portal.kernel.dao.orm.Disjunction)2 Junction (com.liferay.portal.kernel.dao.orm.Junction)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ManifestSummary (com.liferay.exportimport.kernel.lar.ManifestSummary)1 StagedModelType (com.liferay.exportimport.kernel.lar.StagedModelType)1 KBArticle (com.liferay.knowledgebase.model.KBArticle)1 KBArticleActionableDynamicQuery (com.liferay.knowledgebase.service.persistence.KBArticleActionableDynamicQuery)1