use of org.hibernate.engine.query.spi.HQLQueryPlan in project hibernate-orm by hibernate.
the class AbstractProducedQuery method makeQueryParametersForExecution.
protected QueryParameters makeQueryParametersForExecution(String hql) {
final HQLQueryPlan entityGraphHintedQueryPlan;
if (entityGraphQueryHint == null) {
entityGraphHintedQueryPlan = null;
} else {
entityGraphHintedQueryPlan = new HQLQueryPlan(hql, false, getProducer().getLoadQueryInfluencers().getEnabledFilters(), getProducer().getFactory(), entityGraphQueryHint);
}
QueryParameters queryParameters = new QueryParameters(getQueryParameterBindings(), getLockOptions(), queryOptions, true, isReadOnly(), cacheable, cacheRegion, comment, dbHints, null, optionalObject, optionalEntityName, optionalId, resultTransformer);
queryParameters.setQueryPlan(entityGraphHintedQueryPlan);
if (passDistinctThrough != null) {
queryParameters.setPassDistinctThrough(passDistinctThrough);
}
return queryParameters;
}
use of org.hibernate.engine.query.spi.HQLQueryPlan in project hibernate-orm by hibernate.
the class SessionImpl method iterate.
@Override
public Iterator iterate(String query, QueryParameters queryParameters) throws HibernateException {
checkOpenOrWaitingForAutoClose();
checkTransactionSynchStatus();
queryParameters.validateParameters();
HQLQueryPlan plan = queryParameters.getQueryPlan();
if (plan == null) {
plan = getQueryPlan(query, true);
}
autoFlushIfRequired(plan.getQuerySpaces());
// stops flush being called multiple times if this method is recursively called
dontFlushFromFind++;
try {
return plan.performIterate(queryParameters, this);
} finally {
delayedAfterCompletion();
dontFlushFromFind--;
}
}
use of org.hibernate.engine.query.spi.HQLQueryPlan in project hibernate-orm by hibernate.
the class StatelessSessionImpl method list.
// ///////////////////////////////////////////////////////////////////////////////////////////////////
// TODO: COPY/PASTE FROM SessionImpl, pull up!
@Override
public List list(String query, QueryParameters queryParameters) throws HibernateException {
checkOpen();
queryParameters.validateParameters();
HQLQueryPlan plan = getQueryPlan(query, false);
boolean success = false;
List results = Collections.EMPTY_LIST;
try {
results = plan.performList(queryParameters, this);
success = true;
} finally {
afterOperation(success);
}
temporaryPersistenceContext.clear();
return results;
}
use of org.hibernate.engine.query.spi.HQLQueryPlan in project hibernate-orm by hibernate.
the class MultiInheritanceImplicitDowncastTest method testMultiJoinAddition.
private void testMultiJoinAddition(String hql) {
final HQLQueryPlan plan = sessionFactory().getQueryPlanCache().getHQLQueryPlan(hql, false, Collections.EMPTY_MAP);
assertEquals(1, plan.getTranslators().length);
final QueryTranslator translator = plan.getTranslators()[0];
final String generatedSql = translator.getSQLString();
int sub1JoinColumnIndex = generatedSql.indexOf(".base_sub_1");
assertNotEquals("Generated SQL doesn't contain a join for 'base' with 'PolymorphicSub1' via 'base_sub_1':\n" + generatedSql, -1, sub1JoinColumnIndex);
int sub2JoinColumnIndex = generatedSql.indexOf(".base_sub_2");
assertNotEquals("Generated SQL doesn't contain a join for 'base' with 'PolymorphicSub2' via 'base_sub_2':\n" + generatedSql, -1, sub2JoinColumnIndex);
}
use of org.hibernate.engine.query.spi.HQLQueryPlan in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateHQLQueryPlan.
@Test
public void testCreateHQLQueryPlan() {
final Collection<PersistentClass> entityBindings = new ArrayList<PersistentClass>();
final StandardServiceRegistryBuilder standardServiceRegistryBuilder = new StandardServiceRegistryBuilder();
standardServiceRegistryBuilder.applySetting(AvailableSettings.DIALECT, TestDialect.class.getName());
final StandardServiceRegistry serviceRegistry = standardServiceRegistryBuilder.build();
final MetadataSources metadataSources = new MetadataSources(serviceRegistry);
final MetadataImplementor metadata = (MetadataImplementor) metadataSources.buildMetadata();
Table t = new Table("FOO");
Column c = new Column("foo");
t.addColumn(c);
PrimaryKey key = new PrimaryKey(t);
key.addColumn(c);
t.setPrimaryKey(key);
SimpleValue sv = new SimpleValue(metadata);
sv.setNullValue("null");
sv.setTypeName(Integer.class.getName());
sv.setTable(t);
sv.addColumn(c);
final RootClass rc = new RootClass(null);
rc.setEntityName("foo");
rc.setJpaEntityName("foo");
rc.setIdentifier(sv);
rc.setTable(t);
entityBindings.add(rc);
MetadataImplementor wrapper = (MetadataImplementor) Proxy.newProxyInstance(facadeFactory.getClassLoader(), new Class[] { MetadataImplementor.class }, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if ("getEntityBinding".equals(method.getName()) && args != null && args.length == 1 && "foo".equals(args[0])) {
return rc;
} else if ("getEntityBindings".equals(method.getName())) {
return entityBindings;
}
return method.invoke(metadata, args);
}
});
SessionFactoryBuilder sfb = new SessionFactoryBuilderImpl(wrapper);
SessionFactoryImpl sfi = (SessionFactoryImpl) sfb.build();
Map<String, Filter> filters = Collections.emptyMap();
HQLQueryPlan hqlQueryPlan = new HQLQueryPlan("from foo", false, filters, sfi);
IHQLQueryPlan facade = facadeFactory.createHQLQueryPlan(hqlQueryPlan);
assertSame(hqlQueryPlan, ((IFacade) facade).getTarget());
}
Aggregations