public StateObject buildStateObject(StateObject parent,
CharSequence jpqlFragment,
String queryBNFId) {
// First parse the JPQL fragment
JPQLExpression jpqlExpression = parse(jpqlFragment, parent.getGrammar(), queryBNFId);
// We keep track of the old stuff because during the creation of a JPQLQueryStateObject,
// it is possible the state model uses this builder to create some objects
BasicStateObjectBuilder builder = getStateObjectBuilder();
IJPQLQueryBuilder oldBuilder = builder.jpqlQueryBuilder;
IManagedTypeProvider oldProvider = builder.managedTypeProvider;
JPQLQueryStateObject oldParent = builder.parent;
StateObject oldStateObject = builder.stateObject;
try {
builder.jpqlQueryBuilder = this;
builder.managedTypeProvider = parent.getManagedTypeProvider();
builder.parent = parent.getRoot();
builder.stateObject = parent;
// Visit the Expression for which a StateObject is needed
jpqlExpression.getQueryStatement().accept(wrap(builder));
return builder.stateObject;
}
finally {
builder.jpqlQueryBuilder = oldBuilder;