Filters

15 views
Skip to first unread message

Rafael Felini

unread,
Aug 10, 2015, 9:10:11 PM8/10/15
to ActiveJDBC Group
Hi guys, I'm evaluating ActiveJDBC for a new project and I have a doubt.

How can I configure a default filter (more than one) for some models?
To be exactly it is a SaaS and I need multi tenancy, I have one database for all customers with a column discriminator.
Another use case is to filter all models with date deleted not null.

I think in rails this feature is called scopes and in hibernate is filters, so what is the equivalent in ActiveJDBC?

Thanks,
Rafael

Igor Polevoy

unread,
Aug 10, 2015, 11:01:13 PM8/10/15
to ActiveJDBC Group
Hi, Rafael. 

Such feature is not present  in ActiveJDBC. It is typical in AJ to write a wrapper method: 

class MyClass extends Model{
    public static List<MyClass> deletedWhere( String additionalQuery){ 
          where( "date_deleted = NULL and " + additionalQuery) ;
    }
}

The only inconvenience is that you will have to repeat this for each class model, since the methods are static. 

tx

Rafael Felini

unread,
Aug 11, 2015, 4:32:50 PM8/11/15
to ActiveJDBC Group
Hi Igor, thanks for the response, your insight give some ideas to deal with it.

Thanks

Igor Polevoy

unread,
Aug 11, 2015, 9:15:36 PM8/11/15
to ActiveJDBC Group
glad I could help. enjoy 
Reply all
Reply to author
Forward
0 new messages