package ua.com.fielden.platform.security.dao;

import java.util.List;

import ua.com.fielden.platform.dao.CommonEntityDao;
import ua.com.fielden.platform.dao.IUserRoleDao;
import ua.com.fielden.platform.dao.annotations.SessionRequired;
import ua.com.fielden.platform.entity.AbstractEntity;
import ua.com.fielden.platform.entity.query.IFilter;
import ua.com.fielden.platform.entity.query.model.EntityResultQueryModel;
import ua.com.fielden.platform.entity.query.model.OrderingModel;
import ua.com.fielden.platform.security.user.UserRole;
import ua.com.fielden.platform.swing.review.annotations.EntityType;

import com.google.inject.Inject;

import static ua.com.fielden.platform.entity.query.fluent.EntityQueryUtils.from;
import static ua.com.fielden.platform.entity.query.fluent.EntityQueryUtils.orderBy;
import static ua.com.fielden.platform.entity.query.fluent.EntityQueryUtils.select;

/**
 * Db driven implementation of the {@link IUserRoleDao}.
 *
 * @author TG Team
 *
 */
@EntityType(UserRole.class)
public class UserRoleDao extends CommonEntityDao<UserRole> implements IUserRoleDao {

    @Inject
    protected UserRoleDao(final IFilter filter) {
	super(filter);
    }

    @Override
    @SessionRequired
    public List<UserRole> findAll() {
	final EntityResultQueryModel<UserRole> model = select(UserRole.class).model();
	final OrderingModel orderBy = orderBy().prop(AbstractEntity.KEY).asc().model();
	return getAllEntities(from(model).with(orderBy).model());
    }

    @Override
    public List<UserRole> findByIds(final Long... ids) {
	final EntityResultQueryModel<UserRole> model = select(UserRole.class).where().prop(AbstractEntity.ID).in().values(ids).model();
	final OrderingModel orderBy = orderBy().prop(AbstractEntity.KEY).asc().model();
	return getAllEntities(from(model).with(orderBy).model());
    }
}
@@ -40,16 +40,293 @@
 y.dao;%0A%0A
+import static ua.com.fielden.platform.entity.query.fluent.EntityQueryUtils.from;%0Aimport static ua.com.fielden.platform.entity.query.fluent.EntityQueryUtils.orderBy;%0Aimport static ua.com.fielden.platform.entity.query.fluent.EntityQueryUtils.select;%0A%0Aimport java.util.ArrayList;%0A
 import j
@@ -340,16 +340,16 @@
 l.List;%0A
-
 %0Aimport 
@@ -914,257 +914,8 @@
 t;%0A%0A
-import static ua.com.fielden.platform.entity.query.fluent.EntityQueryUtils.from;%0Aimport static ua.com.fielden.platform.entity.query.fluent.EntityQueryUtils.orderBy;%0Aimport static ua.com.fielden.platform.entity.query.fluent.EntityQueryUtils.select;%0A%0A
 /**%0A
@@ -1509,24 +1509,24 @@
   @Override%0A
-
     public L
@@ -1566,24 +1566,106 @@
 g... ids) %7B%0A
+%09if (ids == null %7C%7C ids.length == 0) %7B%0A%09    return new ArrayList%3CUserRole%3E();%0A%09%7D%0A%0A
 %09final Entit

Corrected the behaviour.