Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Tim Cardwell
Adding Modulus to a Dynamic Query
February 19, 2013 2:08 PM
Answer

Tim Cardwell

Rank: Junior Member

Posts: 27

Join Date: July 19, 2012

Recent Posts

Does anyone know how to add a modulus operator to a dynamic query?

For example, lets say i want to make a really simple query like so:
1
2SELECT * FROM ResourcePermission permission
3WHERE permission.companyId = 10154
4AND permission.scope = 4
5AND permission.roleId = 10165
6AND (permission.actionIds % 2) = 1;


This is a valid query in T-SQL.

If I wanted to turn the above into a dynamic query, I would do something like this:
1
2DynamicQuery query = DynamicQueryFactoryUtil.forClass(DLFolder.class, "permission")
3    .add(PropertyFactoryUtil.forName("permission.companyId").eq(10154))
4    .add(PropertyFactoryUtil.forName("permission.scope").eq(4))
5    .add(PropertyFactoryUtil.forName("permission.roleId").eq(10165));
6    // Need to add modulus check


Is it possible to add the modulus operation into a dynamic query operator?

Thanks,
-Tim