"I want to get the paths from a different class which processes the query"
Ok - i see what you are doing. I have never tired this - I have always developed QueryBuilder App Logic using different methods in the same class - not different classes.
You can try passing the QueryBuilder Object itself -- for example -
Servlet Class{
@Reference
private QueryBuilder builder;
@Reference
private ServiceA serA;
@Reference
private ServiceB servB;
@Reference
private ServiceC servC;
doGet
{
serA.getPathA(builder);
serB.getPathB(builder);
serC.getPathC(builder);
}
}
Assuming:
ServiceA - expose method getPathA(QueryBuilder qb)
ServiceB - expose method getPathB(QueryBuilder qb)
ServiceC - expose method getPathB(QueryBuilder qb)
I have never tried this. Since QueryBuilder is a managed object and was created with Dependency Injection, not sure if this will work in other classes or if you will have to re-create it in each service.
Try that and see what happens. I am also assuming that the other classes are also using @Service annotations.
Like I mentioned - i also keep the QueryBuilder logic in the same class as it's defined as a data member of the class and can be used in many class methods without issue.
Also since you need a session - you may have to re-create the session in each class as well:
builder.createQuery(PredicateGroup.create(map), session)