Search code examples
javaspringspring-roo

Why doesn't Roo generate Spring repository query methods for finder


I am using spring roo to develop a small web application. I used the finder commands to add few finder APIs. After removing Roo with Push-in, the code generated is following in the model class

public static TypedQuery<Task> findTasksByAssignedTo(Employee assignedTo) {
    if (assignedTo == null) throw new IllegalArgumentException("The assignedTo argument is required");
    EntityManager em = Task.entityManager();
    TypedQuery<Task> q = em.createQuery("SELECT o FROM Task AS o WHERE o.assignedTo = :assignedTo", Task.class);
    q.setParameter("assignedTo", assignedTo);
    return q;
}

Why doesn't Roo just generate findBy methods in the Repository interface? Or does it support something like this that I am not aware of?


Solution

  • Because by default Roo use the Active Record Pattern and does not use DAOs.

    Active Record Pattern:

    An object that wraps a row in a database table or view, encapsulates the database access, and adds domain logic on that data."