Reputation: 45
I have a Employee object for example, Employee contains several fields (300+) like name, department, salary, age, account, etc. Entire Employee table data cached into java List object , which contains 2+ million records.
Requirement user can search on any filed presents in Employee object like employee name like Sehwag and age > 30 or salary > 100000, Based on user search we have to show filtered list of Employee list.
due to performance issues we are not querying DB, we want to apply the user search criteria on cached java List object earlier
is there way api / frameworks / any other solution where we can query on java objects?
below approach I am trying but I am feeling not a good approach
Iterating the Employee list and applying condition user search criteria on employee object, to know the user selected search criteria among 300 fields is challenging, written a lot enum mapping logic and some additional logic for every filed to make it work. with current requirement it may works but thinking to use api or framework or better way to solve the requirement!
thanks in advance for your help.
Upvotes: 0
Views: 2243
Reputation: 45
tried CQEngine's SQL based queries https://github.com/npgall/cqengine suits to my requirement,
below are some useful links https://dzone.com/articles/getting-started-cqengine-linq
https://mvnrepository.com/artifact/com.googlecode.cqengine/cqengine
Upvotes: 0
Reputation: 116
First of all. If you either don't want or don't have chance to change the existing solution, take a look at querydsl. There is a querydsl-collection module which fits exactly with your need. See more at http://www.querydsl.com/ and http://www.querydsl.com/static/querydsl/latest/reference/html/ch02s08.html
However, if you have a chance to review/rebuild the solution, you should consider something more appropriate for large volume querying. I suggest you exploring more about nonsql databases (mongodb) or indexing tools such as lucene or elasticsearch which adds a RESTFul layer on top of lucene.
I hope it helps.
Upvotes: 1