I have a model that has several properties. Properties can be primitive (String) or complex (Object). The user can make a request for each property of the primitive. I would like to know if there is an easy way to dynamically build a query. I use Java and Hibernate.
Model
public class Model {
String prop1;
Point prop2;
List<Shape> prop3;
}
Pointand Shape- an object that may contain primitives or objects. An example of a query would be all instances where prop1 = "A", and the coordinates are x = 3 and y = 8, and one of the figures is a circle.
prop1 = "A" and prop2.x = 3 and prop2.y and prop3.get (i) .type = "Circle"; we would have to iterate over all instances of prop3.
My first idea was unattainable and ineffective. It consists in executing queries on all the primitive properties and then merging the results.
- Get all instances where prop1 = "A"
- Get all instances where prop2.x = 3 and prop3 = y;
- Get all instances in which one of Shape.type = "Circle";
- Get the intersection of all three sets
Is there any existing library or algorithm that can solve this problem better (smarter)?
thank
source
share