Search code examples
javasqlcollections

How do you query object collections in Java (Criteria/SQL-like)?


Suppose you have a collection of a few hundred in-memory objects and you need to query this List to return objects matching some SQL or Criteria like query. For example, you might have a List of Car objects and you want to return all cars made during the 1960s, with a license plate that starts with AZ, ordered by the name of the car model.

I know about JoSQL, has anyone used this, or have any experience with other/homegrown solutions?


Solution

  • I have used Apache Commons JXPath in a production application. It allows you to apply XPath expressions to graphs of objects in Java.