spring roo conditional database request

45 views Asked by At

Is there any automatic way to create conditional database request with Spring roo? For example, I have Book class and this class has page attribute. I want to list books which has more than 100 page.

1

There are 1 answers

0
jmvivo On BEST ANSWER

There is no way to generate it automatically, but you can create it on your Book class. By example:

@RooJavaBean
@RooToString
@RooJpaActiveRecord
public class Book {


   public int pages;

   // ...
   // ...
   // ...
   public static List<Book> findLargeBooks() {

        return entityManager().createQuery(
            "Select o from Book o where o.pages > 100", Book.class).getResultList();

   }


}