org.hibernate.loader.custom.sql.SQLCustomQuery Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-core Show documentation
Show all versions of hibernate-core Show documentation
JPMS Module-Info's for a few of the Jakarta Libraries just until they add them in themselves
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.loader.custom.sql;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.hibernate.HibernateException;
import org.hibernate.engine.query.spi.sql.NativeSQLQueryReturn;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.loader.custom.CustomQuery;
import org.hibernate.param.ParameterBinder;
import org.hibernate.persister.collection.SQLLoadableCollection;
import org.hibernate.persister.entity.SQLLoadable;
import org.jboss.logging.Logger;
/**
* Implements Hibernate's built-in support for native SQL queries.
*
* This support is built on top of the notion of "custom queries"...
*
* @author Gavin King
* @author Max Andersen
* @author Steve Ebersole
*/
public class SQLCustomQuery implements CustomQuery, Serializable {
private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, SQLCustomQuery.class.getName() );
private final String sql;
private final Set querySpaces = new HashSet();
private final List paramValueBinders;
private final List customQueryReturns = new ArrayList();
public String getSQL() {
return sql;
}
public Set getQuerySpaces() {
return querySpaces;
}
@Override
public List getParameterValueBinders() {
return paramValueBinders;
}
public List getCustomQueryReturns() {
return customQueryReturns;
}
public SQLCustomQuery(
final String sqlQuery,
final NativeSQLQueryReturn[] queryReturns,
final Collection additionalQuerySpaces,
final SessionFactoryImplementor factory) throws HibernateException {
LOG.tracev( "Starting processing of sql query [{0}]", sqlQuery );
SQLQueryReturnProcessor processor = new SQLQueryReturnProcessor(queryReturns, factory);
SQLQueryReturnProcessor.ResultAliasContext aliasContext = processor.process();
// Map[] propertyResultMaps = (Map[]) processor.getPropertyResults().toArray( new Map[0] );
// Map[] collectionResultMaps = (Map[]) processor.getCollectionPropertyResults().toArray( new Map[0] );
//
// List collectionSuffixes = new ArrayList();
// List collectionOwnerAliases = processor.getCollectionOwnerAliases();
// List collectionPersisters = processor.getCollectionPersisters();
// int size = collectionPersisters.size();
// if (size!=0) {
// collectionOwners = new int[size];
// collectionRoles = new String[size];
// //collectionDescriptors = new CollectionAliases[size];
// for ( int i=0; i