Firstly,let me say, that the example I show here is very simple and very far from the real situation. However this example shows the core of the problem well enough.
I have a class Person
public class Person{
private int Id;
private String firstName;
private String lastName;
private Date birthDate;
private int age;
//+ getters and setters
}
And I have for example list of 2000 java(!) objects of this class. I mean I have 2000 persons. Now I need to filter and sort them using sql query. For example I would like to get the persons from these 2000 WHERE birthDate BETWEEN 1920-04-05 AND 2000-08-10 ORDER BY lastName,firstName
.
I understand that sql language is part of sql database.s So I could save my objects to mem database,for example H2, after that do select with the necessary WHERE
and ORDER
clauses. However, the problem is that I this case lose performance as I already have these objects. What I need is just to get the list of the ID of these objects and that's all as I get the interval and order.
So my question - are there any solutions (libs etc) to make filtering and sorting on java objects including all common types? Maybe there are some,that even support sql language?