All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.loader.custom.sql.SQLCustomQuery Maven / Gradle / Ivy

There is a newer version: 3.6.0.Beta2
Show newest version
//$Id: SQLCustomQuery.java 10018 2006-06-15 05:21:06Z [email protected] $
package org.hibernate.loader.custom.sql;

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 java.util.HashMap;

import org.hibernate.HibernateException;
import org.hibernate.engine.query.sql.NativeSQLQueryReturn;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.loader.custom.CustomQuery;
import org.hibernate.persister.collection.SQLLoadableCollection;
import org.hibernate.persister.entity.SQLLoadable;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * 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 { public static final Log log = LogFactory.getLog( SQLCustomQuery.class ); private final String sql; private final Set querySpaces = new HashSet(); private final Map namedParameterBindPoints = new HashMap(); private final List customQueryReturns = new ArrayList(); public String getSQL() { return sql; } public Set getQuerySpaces() { return querySpaces; } public Map getNamedParameterBindPoints() { return namedParameterBindPoints; } public List getCustomQueryReturns() { return customQueryReturns; } public SQLCustomQuery( final String sqlQuery, final NativeSQLQueryReturn[] queryReturns, final Collection additionalQuerySpaces, final SessionFactoryImplementor factory) throws HibernateException { log.trace( "starting processing of sql query [" + 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





© 2015 - 2024 Weber Informatics LLC | Privacy Policy