Tabnine Logo
Loader
Code IndexAdd Tabnine to your IDE (free)

How to use
Loader
in
org.hibernate.loader

Best Java code snippets using org.hibernate.loader.Loader (Showing top 20 results out of 315)

origin: hibernate/hibernate-orm

private ResultSet processResultSet(
    ResultSet rs,
    final RowSelection selection,
    final LimitHandler limitHandler,
    final boolean autodiscovertypes,
    final SharedSessionContractImplementor session
) throws SQLException, HibernateException {
  rs = wrapResultSetIfEnabled( rs, session );
  if ( !limitHandler.supportsLimitOffset() || !LimitHelper.useLimit( limitHandler, selection ) ) {
    advance( rs, selection );
  }
  if ( autodiscovertypes ) {
    autoDiscoverTypes( rs );
  }
  return rs;
}
origin: hibernate/hibernate-orm

/**
 * Modify the SQL, adding lock hints and comments, if necessary
 */
protected String preprocessSQL(
    String sql,
    QueryParameters parameters,
    SessionFactoryImplementor sessionFactory,
    List<AfterLoadAction> afterLoadActions) throws HibernateException {
  Dialect dialect = sessionFactory.getServiceRegistry().getService( JdbcServices.class ).getDialect();
  sql = applyLocks( sql, parameters, dialect, afterLoadActions );
  sql = dialect.addSqlHintOrComment(
    sql,
    parameters,
    sessionFactory.getSessionFactoryOptions().isCommentsEnabled()
  );
  return processDistinctKeyword( sql, parameters );
}
origin: hibernate/hibernate-orm

/**
 * Bind all parameter values into the prepared statement in preparation
 * for execution.
 *
 * @param statement The JDBC prepared statement
 * @param queryParameters The encapsulation of the parameter values to be bound.
 * @param startIndex The position from which to start binding parameter values.
 * @param session The originating session.
 *
 * @return The number of JDBC bind positions actually bound during this method execution.
 *
 * @throws SQLException Indicates problems performing the binding.
 */
protected int bindParameterValues(
    PreparedStatement statement,
    QueryParameters queryParameters,
    int startIndex,
    SharedSessionContractImplementor session) throws SQLException {
  int span = 0;
  span += bindPositionalParameters( statement, queryParameters, startIndex, session );
  span += bindNamedParameters( statement, queryParameters.getNamedParameters(), startIndex + span, session );
  return span;
}
origin: hibernate/hibernate-orm

  int maxRows,
  List<AfterLoadAction> afterLoadActions) throws SQLException {
final int entitySpan = getEntityPersisters().length;
final EntityKey optionalObjectKey = getOptionalObjectKey( queryParameters, session );
final LockMode[] lockModesArray = getLockModes( queryParameters.getLockOptions() );
final boolean createSubselects = isSubselectLoadingEnabled();
final List subselectResultKeys = createSubselects ? new ArrayList() : null;
final ArrayList hydratedObjects = entitySpan == 0 ? null : new ArrayList( entitySpan * 10 );
final List results = new ArrayList();
handleEmptyCollections( queryParameters.getCollectionKeys(), rs, session );
EntityKey[] keys = new EntityKey[entitySpan]; //we can reuse it for each row
LOG.trace( "Processing result set" );
    LOG.debugf( "Result set row: %s", count );
  Object result = getRowFromResultSet(
      rs,
      session,
initializeEntitiesAndCollections(
    hydratedObjects,
    rs,
);
if ( createSubselects ) {
  createSubselects( subselectResultKeys, queryParameters, session );
origin: hibernate/hibernate

final int maxRows = hasMaxRows( selection ) ?
    selection.getMaxRows().intValue() :
    Integer.MAX_VALUE;
final int entitySpan = getEntityPersisters().length;
final PreparedStatement st = prepareQueryStatement( queryParameters, false, session );
final ResultSet rs = getResultSet( st, queryParameters.isCallable(), selection, session );
final LockMode[] lockModeArray = getLockModes( queryParameters.getLockModes() );
final EntityKey optionalObjectKey = getOptionalObjectKey( queryParameters, session );
final boolean createSubselects = isSubselectLoadingEnabled();
final List subselectResultKeys = createSubselects ? new ArrayList() : null;
  handleEmptyCollections( queryParameters.getCollectionKeys(), rs, session );
    Object result = getRowFromResultSet( rs,
        session,
        queryParameters,
initializeEntitiesAndCollections( hydratedObjects, rs, session, queryParameters.isReadOnly() );
if ( createSubselects ) createSubselects( subselectResultKeys, queryParameters, session );
origin: hibernate/hibernate-orm

  final EntityKey[] keys,
  boolean returnProxies) throws SQLException, HibernateException {
return getRowFromResultSet(
    resultSet,
    session,
  boolean returnProxies,
  ResultTransformer forcedResultTransformer) throws SQLException, HibernateException {
final Loadable[] persisters = getEntityPersisters();
final int entitySpan = persisters.length;
extractKeysFromResultSet(
    persisters,
    queryParameters,
registerNonExists( keys, persisters, session );
Object[] row = getRow(
    resultSet,
    persisters,
readCollectionElements( row, resultSet, session );
applyPostLoadLocks( row, lockModesArray, session );
    ? getResultColumnOrRow( row, queryParameters.getResultTransformer(), resultSet, session )
    : forcedResultTransformer.transformTuple(
    getResultRow( row, resultSet, session ),
    getResultRowAliases()
origin: hibernate/hibernate-orm

/**
 * Called by subclasses that batch initialize collections
 */
protected final void loadCollectionSubselect(
    final SharedSessionContractImplementor session,
    final Serializable[] ids,
    final Object[] parameterValues,
    final Type[] parameterTypes,
    final Map<String, TypedValue> namedParameters,
    final Type type) throws HibernateException {
  final Type[] idTypes = new Type[ids.length];
  Arrays.fill( idTypes, type );
  try {
    doQueryAndInitializeNonLazyCollections(
        session,
        new QueryParameters( parameterTypes, parameterValues, namedParameters, ids ),
        true
    );
  }
  catch (SQLException sqle) {
    throw factory.getJdbcServices().getSqlExceptionHelper().convert(
        sqle,
        "could not load collection by subselect: " +
            MessageHelper.collectionInfoString( getCollectionPersisters()[0], ids, getFactory() ),
        getSQLString()
    );
  }
}
origin: hibernate/hibernate-orm

  throws HibernateException {
final boolean stats = getFactory().getStatistics().isStatisticsEnabled();
long startTime = 0;
if ( stats ) {
  result = doQueryAndInitializeNonLazyCollections( session, queryParameters, true, forcedResultTransformer );
      sqle,
      "could not execute query",
      getSQLString()
  );
  final long endTime = System.nanoTime();
  final long milliseconds = TimeUnit.MILLISECONDS.convert( endTime - startTime, TimeUnit.NANOSECONDS );
  getFactory().getStatistics().queryExecuted(
      getQueryIdentifier(),
      result.size(),
      milliseconds
origin: hibernate/hibernate-orm

  LockOptions lockOptions) throws HibernateException {
if ( LOG.isDebugEnabled() ) {
  LOG.debugf( "Batch loading entity: %s", MessageHelper.infoString( persister, ids, getFactory() ) );
  qp.setOptionalId( optionalId );
  qp.setLockOptions( lockOptions );
  result = doQueryAndInitializeNonLazyCollections( session, qp, false );
      sqle,
      "could not load an entity batch: " +
          MessageHelper.infoString( getEntityPersisters()[0], ids, getFactory() ),
      getSQLString()
  );
origin: jboss.jboss-embeddable-ejb3/hibernate-all

Dialect dialect = getFactory().getDialect();
if (callable) {
  rs = session.getBatcher().getResultSet( (CallableStatement) st, dialect );
  rs = session.getBatcher().getResultSet( st );
rs = wrapResultSetIfEnabled( rs , session );
  advance( rs, selection );
  autoDiscoverTypes( rs );
origin: hibernate/hibernate

queryParameters.processFilters( getSQLString(), session );
String sql = queryParameters.getFilteredSQL();
final Dialect dialect = getFactory().getDialect();
final RowSelection selection = queryParameters.getRowSelection();
boolean useLimit = useLimit( selection, dialect );
boolean hasFirstRow = getFirstRow( selection ) > 0;
boolean useOffset = hasFirstRow && useLimit && dialect.supportsLimitOffset();
boolean callable = queryParameters.isCallable();
    getFactory().getSettings().isScrollableResultSetsEnabled();
ScrollMode scrollMode = scroll ? queryParameters.getScrollMode() : ScrollMode.SCROLL_INSENSITIVE;
      useOffset ? getFirstRow(selection) : 0, 
      getMaxOrLimit(selection, dialect) 
  );
sql = preprocessSQL( sql, queryParameters, dialect );
    col += bindLimitParameters( st, col, selection );
  col += bindPositionalParameters( st, queryParameters, col, session );
  col += bindNamedParameters( st, queryParameters.getNamedParameters(), col, session );
    col += bindLimitParameters( st, col, selection );
  if ( !useLimit ) setMaxRows( st, selection );
  if ( selection != null ) {
    if ( selection.getTimeout() != null ) {
origin: hibernate/hibernate-orm

private void createSubselects(List keys, QueryParameters queryParameters, SharedSessionContractImplementor session) {
  if ( keys.size() > 1 ) { //if we only returned one entity, query by key is more efficient
    Set[] keySets = transpose( keys );
    Map namedParameterLocMap = buildNamedParameterLocMap( queryParameters );
    final Loadable[] loadables = getEntityPersisters();
    final String[] aliases = getAliases();
    final String subselectQueryString = SubselectFetch.createSubselectFetchQueryFragment( queryParameters );
    for ( Object key : keys ) {
      final EntityKey[] rowKeys = (EntityKey[]) key;
      for ( int i = 0; i < rowKeys.length; i++ ) {
        if ( rowKeys[i] != null && loadables[i].hasSubselectLoadableCollections() ) {
          SubselectFetch subselectFetch = new SubselectFetch(
              subselectQueryString,
              aliases[i],
              loadables[i],
              queryParameters,
              keySets[i],
              namedParameterLocMap
          );
          session.getPersistenceContext()
              .getBatchFetchQueue()
              .addSubselect( rowKeys[i], subselectFetch );
        }
      }
    }
  }
}
origin: org.hibernate/com.springsource.org.hibernate

/**
 * Modify the SQL, adding lock hints and comments, if necessary
 */
protected String preprocessSQL(String sql, QueryParameters parameters, Dialect dialect)
    throws HibernateException {
  sql = applyLocks( sql, parameters.getLockOptions(), dialect );
  return getFactory().getSettings().isCommentsEnabled() ?
      prependComment( sql, parameters ) : sql;
}
origin: hibernate/hibernate-orm

result = doQueryAndInitializeNonLazyCollections(
    session,
    new QueryParameters(
    sqle,
    "could not load collection element by index",
    getSQLString()
);
origin: hibernate/hibernate-orm

if ( LockMode.NONE != requestedLockMode && upgradeLocks() ) { //no point doing this if NONE was requested
  final EntityEntry entry = session.getPersistenceContext().getEntry( object );
  if ( entry.getLockMode().lessThan( requestedLockMode ) ) {
      checkVersion( i, persister, key.getIdentifier(), object, rs, session );
origin: hibernate/hibernate-orm

  List<AfterLoadAction> afterLoadActions) throws HibernateException {
final CollectionPersister[] collectionPersisters = getCollectionPersisters();
if ( collectionPersisters != null ) {
  for ( CollectionPersister collectionPersister : collectionPersisters ) {
      endCollectionLoad( resultSetId, session, collectionPersister );
      endCollectionLoad( resultSetId, session, collectionPersister );
origin: hibernate/hibernate

private void createSubselects(List keys, QueryParameters queryParameters, SessionImplementor session) {
  if ( keys.size() > 1 ) { //if we only returned one entity, query by key is more efficient
    Set[] keySets = transpose(keys);
    final Loadable[] loadables = getEntityPersisters();
    final String[] aliases = getAliases();
    final Iterator iter = keys.iterator();
    while ( iter.hasNext() ) {
origin: hibernate/hibernate

final PostLoadEvent post = new PostLoadEvent(session);
final CollectionPersister[] collectionPersisters = getCollectionPersisters();
if ( collectionPersisters != null ) {
  for ( int i=0; i<collectionPersisters.length; i++ ) {
      endCollectionLoad( resultSetId, session, collectionPersisters[i] );
if ( getEntityPersisters().length > 0 ) { //if no persisters, hydratedObjects is null
  int hydratedObjectsSize = hydratedObjects.size();
  if ( log.isTraceEnabled() ) log.trace( "total objects hydrated: " + hydratedObjectsSize );
      endCollectionLoad( resultSetId, session, collectionPersisters[i] );
origin: hibernate/hibernate-orm

try {
  try {
    result = doQuery( session, queryParameters, returnProxies, forcedResultTransformer );
origin: hibernate/hibernate-orm

/**
 * Execute an SQL query and attempt to instantiate instances of the class mapped by the given
 * persister from each row of the <tt>ResultSet</tt>. If an object is supplied, will attempt to
 * initialize that object. If a collection is supplied, attempt to initialize that collection.
 */
public List doQueryAndInitializeNonLazyCollections(
    final SharedSessionContractImplementor session,
    final QueryParameters queryParameters,
    final boolean returnProxies) throws HibernateException, SQLException {
  return doQueryAndInitializeNonLazyCollections(
      session,
      queryParameters,
      returnProxies,
      null
  );
}
org.hibernate.loaderLoader

Javadoc

Abstract superclass of object loading (and querying) strategies. This class implements useful common functionality that concrete loaders delegate to. It is not intended that this functionality would be directly accessed by client code. (Hence, all methods of this class are declared protected or private.) This class relies heavily upon the Loadable interface, which is the contract between this class and EntityPersisters that may be loaded by it.

The present implementation is able to load any number of columns of entities and at most one collection role per query.

Most used methods

  • advance
    Advance the cursor to the first required row of the ResultSet
  • applyLocks
    Append FOR UPDATE OF clause, if necessary. This empty superclass implementation merely returns its f
  • bindNamedParameters
    Bind named parameters to the JDBC prepared statement. This is a generic implementation, the problem
  • bindPositionalParameters
    Bind positional parameter values to the JDBC prepared statement. Positional parameters are those spe
  • checkVersion
    Check the version of the object in the ResultSet against the object version in the session cache, th
  • createSubselects
  • doQuery
  • doQueryAndInitializeNonLazyCollections
  • endCollectionLoad
  • getAliases
    Get the SQL table aliases of entities whose associations are subselect-loadable, returning null if t
  • getCollectionAliases
  • getCollectionOwners
    Get the index of the entity that owns the collection, or -1 if there is no owner in the query result
  • getCollectionAliases,
  • getCollectionOwners,
  • getCollectionPersisters,
  • getEntityAliases,
  • getEntityEagerPropertyFetches,
  • getEntityPersisters,
  • getFactory,
  • getInstanceClass,
  • getKeyFromResultSet,
  • getLockModes

Popular in Java

  • Creating JSON documents from java classes using gson
  • getResourceAsStream (ClassLoader)
  • getContentResolver (Context)
  • startActivity (Activity)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now