congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
org.hibernate.engine
Code IndexAdd Tabnine to your IDE (free)

How to use org.hibernate.engine

Best Java code snippets using org.hibernate.engine (Showing top 20 results out of 927)

origin: hibernate/hibernate-orm

  public static boolean isJoinFetched(FetchStrategy fetchStrategy) {
    return fetchStrategy.getTiming() == FetchTiming.IMMEDIATE
        && fetchStrategy.getStyle() == FetchStyle.JOIN;
  }
}
origin: hibernate/hibernate-orm

  public static String toXml(OptimisticLockStyle lockMode) {
    return lockMode == null ? null : lockMode.name().toLowerCase( Locale.ENGLISH );
  }
}
origin: hibernate/hibernate-orm

public static OptimisticLockStyle fromXml(String name) {
  return OptimisticLockStyle.valueOf( name == null ? null : name.toUpperCase( Locale.ENGLISH ) );
}
origin: hibernate/hibernate-orm

@Override
public NativeQuery setResultSetMapping(String name) {
  ResultSetMappingDefinition mapping = getProducer().getFactory().getNamedQueryRepository().getResultSetMappingDefinition( name );
  if ( mapping == null ) {
    throw new MappingException( "Unknown SqlResultSetMapping [" + name + "]" );
  }
  NativeSQLQueryReturn[] returns = mapping.getQueryReturns();
  queryReturns.addAll( Arrays.asList( returns ) );
  return this;
}
origin: hibernate/hibernate-orm

protected FetchStrategy adjustJoinFetchIfNeeded(
    AssociationAttributeDefinition attributeDefinition, FetchStrategy fetchStrategy) {
  if ( lockMode.greaterThan( LockMode.READ ) ) {
    return new FetchStrategy( fetchStrategy.getTiming(), FetchStyle.SELECT );
  }
  final Integer maxFetchDepth = sessionFactory().getSettings().getMaximumFetchDepth();
  if ( maxFetchDepth != null && currentDepth() > maxFetchDepth ) {
    return new FetchStrategy( fetchStrategy.getTiming(), FetchStyle.SELECT );
  }
  if ( attributeDefinition.getType().isCollectionType() && isTooManyCollections() ) {
    // todo : have this revert to batch or subselect fetching once "sql gen redesign" is in place
    return new FetchStrategy( fetchStrategy.getTiming(), FetchStyle.SELECT );
  }
  return fetchStrategy;
}
origin: hibernate/hibernate-orm

/**
 * Close an {@link Iterator} instances obtained from {@link org.hibernate.Query#iterate()} immediately
 * instead of waiting until the session is closed or disconnected.
 *
 * @param iterator an Iterator created by iterate()
 *
 * @throws HibernateException Indicates a problem closing the Hibernate iterator.
 * @throws IllegalArgumentException If the Iterator is not a "Hibernate Iterator".
 *
 * @see Query#iterate()
 */
public static void close(Iterator iterator) throws HibernateException {
  if ( iterator instanceof HibernateIterator ) {
    ( (HibernateIterator) iterator ).close();
  }
  else {
    throw new IllegalArgumentException( "not a Hibernate iterator" );
  }
}
origin: hibernate/hibernate-orm

public void applyResultSetMapping(ResultSetMappingDefinition resultSetMappingDefinition) {
  final ResultSetMappingDefinition old = sqlResultSetMappingMap.put(
      resultSetMappingDefinition.getName(),
      resultSetMappingDefinition
  );
  if ( old != null ) {
    throw new DuplicateMappingException(
        DuplicateMappingException.Type.RESULT_SET_MAPPING,
        resultSetMappingDefinition.getName()
    );
  }
}
origin: hibernate/hibernate-orm

private static void bind(
    ResultSetMappingBindingDefinition resultSetMappingSource,
    ResultSetMappingDefinition binding,
    HbmLocalMetadataBuildingContext context) {
  int cnt = 0;
  for ( Object valueMappingSource : resultSetMappingSource.getValueMappingSources() ) {
    if ( JaxbHbmNativeQueryReturnType.class.isInstance( valueMappingSource ) ) {
      binding.addQueryReturn(
          extractReturnDescription( (JaxbHbmNativeQueryReturnType) valueMappingSource, context, cnt++ )
      );
    }
    else if ( JaxbHbmNativeQueryCollectionLoadReturnType.class.isInstance( valueMappingSource ) ) {
      binding.addQueryReturn(
          extractReturnDescription( (JaxbHbmNativeQueryCollectionLoadReturnType) valueMappingSource, context, cnt++ )
      );
    }
    else if ( JaxbHbmNativeQueryJoinReturnType.class.isInstance( valueMappingSource ) ) {
      binding.addQueryReturn(
          extractReturnDescription( (JaxbHbmNativeQueryJoinReturnType) valueMappingSource, context, cnt++ )
      );
    }
    else if ( JaxbHbmNativeQueryScalarReturnType.class.isInstance( valueMappingSource ) ) {
      binding.addQueryReturn(
          extractReturnDescription( (JaxbHbmNativeQueryScalarReturnType) valueMappingSource, context )
      );
    }
  }
}
origin: hibernate/hibernate-orm

  @Override
  public void doSecondPass(Map persistentClasses) throws MappingException {
    final ResultSetMappingDefinition resultSetMappingDefinition =
        ResultSetMappingBinder.bind( implicitResultSetMappingDefinition, context );
    context.getMetadataCollector().addResultSetMapping( resultSetMappingDefinition );
    NativeSQLQueryReturn[] newQueryReturns = resultSetMappingDefinition.getQueryReturns();
    final NamedSQLQueryDefinition queryDefinition =
        context.getMetadataCollector().getNamedNativeQueryDefinition( queryName );
    if ( queryDefinition != null ) {
      queryDefinition.addQueryReturns( newQueryReturns );
    }
  }
}
origin: hibernate/hibernate-orm

/**
 * Build a ResultSetMappingDefinition given a containing element for the "return-XXX" elements
 *
 * @param resultSetMappingSource The XML data as a JAXB binding
 * @param context The mapping state
 * @param prefix A prefix to apply to named ResultSet mapping; this is either {@code null} for
 * ResultSet mappings defined outside of any entity, or the name of the containing entity
 * if defined within the context of an entity
 *
 * @return The ResultSet mapping descriptor
 */
public static ResultSetMappingDefinition bind(
    ResultSetMappingBindingDefinition resultSetMappingSource,
    HbmLocalMetadataBuildingContext context,
    String prefix) {
  if ( StringHelper.isEmpty( prefix ) ) {
    throw new AssertionFailure( "Passed prefix was null; perhaps you meant to call the alternate #bind form?" );
  }
  final String resultSetName = prefix + '.' + resultSetMappingSource.getName();
  final ResultSetMappingDefinition binding = new ResultSetMappingDefinition( resultSetName );
  bind( resultSetMappingSource, binding, context );
  return binding;
}
origin: hibernate/hibernate-orm

@Override
public FetchStrategy determineFetchPlan(LoadQueryInfluencers loadQueryInfluencers, PropertyPath propertyPath) {
  final EntityPersister owningPersister = getSource().locateOwningPersister();
  FetchStyle style = FetchStrategyHelper.determineFetchStyleByProfile(
      loadQueryInfluencers,
      owningPersister,
      propertyPath,
      attributeNumber()
  );
  if ( style == null ) {
    style = determineFetchStyleByMetadata( getFetchMode(), getType() );
  }
  return new FetchStrategy( determineFetchTiming( style ), style );
}
origin: hibernate/hibernate-orm

/**
 * @deprecated prefer {@link #getOptimisticLockStyle}
 */
@Deprecated
public int getOptimisticLockMode() {
  return getOptimisticLockStyle().getOldCode();
}
origin: hibernate/hibernate-orm

/**
 * @deprecated prefer {@link #setOptimisticLockStyle}
 */
@Deprecated
public void setOptimisticLockMode(int optimisticLockMode) {
  setOptimisticLockStyle( OptimisticLockStyle.interpretOldCode( optimisticLockMode ) );
}
origin: hibernate/hibernate-orm

  public boolean shouldIncludeJoin(FetchStrategy fetchStrategy) {
    return fetchStrategy.getTiming() == FetchTiming.IMMEDIATE && fetchStrategy.getStyle() == FetchStyle.JOIN;
  }
}
origin: hibernate/hibernate-orm

@Override
public void addDefaultResultSetMapping(ResultSetMappingDefinition definition) {
  final String name = definition.getName();
  if ( !defaultSqlResultSetMappingNames.contains( name ) && sqlResultSetMappingMap.containsKey( name ) ) {
    sqlResultSetMappingMap.remove( name );
  }
  applyResultSetMapping( definition );
  defaultSqlResultSetMappingNames.add( name );
}
origin: hibernate/hibernate-orm

@Override
public FetchStrategy determineFetchPlan(LoadQueryInfluencers loadQueryInfluencers, PropertyPath propertyPath) {
  final EntityPersister owningPersister = getSource().getEntityPersister();
  FetchStyle style = FetchStrategyHelper.determineFetchStyleByProfile(
      loadQueryInfluencers,
      owningPersister,
      propertyPath,
      attributeNumber()
  );
  if ( style == null ) {
    style = FetchStrategyHelper.determineFetchStyleByMetadata(
        ( (OuterJoinLoadable) getSource().getEntityPersister() ).getFetchMode( attributeNumber() ),
        getType(),
        sessionFactory()
    );
  }
  return new FetchStrategy(
      FetchStrategyHelper.determineFetchTiming( style, getType(), sessionFactory() ),
      style
  );
}
origin: hibernate/hibernate-orm

@Override
protected FetchStrategy determineFetchStrategy(AssociationAttributeDefinition attributeDefinition) {
  FetchStrategy fetchStrategy = attributeDefinition.determineFetchPlan( loadQueryInfluencers, currentPropertyPath );
  if ( fetchStrategy.getTiming() == FetchTiming.IMMEDIATE && fetchStrategy.getStyle() == FetchStyle.JOIN ) {
    // see if we need to alter the join fetch to another form for any reason
    fetchStrategy = adjustJoinFetchIfNeeded( attributeDefinition, fetchStrategy );
  }
  return fetchStrategy;
}
origin: hibernate/hibernate-orm

@Override
public void addResultSetMapping(ResultSetMappingDefinition resultSetMappingDefinition) {
  if ( resultSetMappingDefinition == null ) {
    throw new IllegalArgumentException( "Result-set mapping was null" );
  }
  final String name = resultSetMappingDefinition.getName();
  if ( name == null ) {
    throw new IllegalArgumentException( "Result-set mapping name is null: " + resultSetMappingDefinition );
  }
  if ( defaultSqlResultSetMappingNames.contains( name ) ) {
    return;
  }
  applyResultSetMapping( resultSetMappingDefinition );
}
origin: hibernate/hibernate-orm

@Override
protected FetchStrategy resolveImplicitFetchStrategyFromEntityGraph(
    final AssociationAttributeDefinition attributeDefinition) {
  FetchStrategy fetchStrategy = attributeDefinition.determineFetchPlan(
      loadQueryInfluencers,
      currentPropertyPath
  );
  if ( fetchStrategy.getTiming() == FetchTiming.IMMEDIATE && fetchStrategy.getStyle() == FetchStyle.JOIN ) {
    // see if we need to alter the join fetch to another form for any reason
    fetchStrategy = adjustJoinFetchIfNeeded( attributeDefinition, fetchStrategy );
  }
  return fetchStrategy;
}
origin: hibernate/hibernate-orm

public void processingFetch(Fetch fetch) {
  if ( ! hasSubselectFetch ) {
    if ( fetch.getFetchStrategy().getStyle() == FetchStyle.SUBSELECT
        && fetch.getFetchStrategy().getTiming() != FetchTiming.IMMEDIATE ) {
      hasSubselectFetch = true;
    }
  }
  if ( isJoinFetchedBag( fetch ) ) {
    if ( joinedBagAttributeFetches == null ) {
      joinedBagAttributeFetches = new HashSet<>();
    }
    joinedBagAttributeFetches.add( (CollectionAttributeFetch) fetch );
  }
}
org.hibernate.engine

Most used classes

  • SessionFactoryImplementor
    Defines the internal contract between the SessionFactory and other parts of Hibernate such as implem
  • SessionImplementor
    Defines the internal contract between org.hibernate.Session / org.hibernate.StatelessSession and oth
  • JdbcServices
    Contract for services around JDBC operations. These represent shared resources, aka not varied by se
  • SessionFactoryImplementor
    Defines the internal contract between the SessionFactory and other parts of Hibernate such as implem
  • PersistenceContext
    Represents the state of "stuff" Hibernate is tracking, including (not exhaustive): * entities * col
  • JtaPlatform,
  • ConfigurationService,
  • JdbcCoordinator,
  • SqlExceptionHelper,
  • RowSelection,
  • SqlStatementLogger,
  • EntityEntry,
  • QueryParameters,
  • SharedSessionContractImplementor,
  • ConnectionProvider,
  • Formatter,
  • SessionImplementor,
  • StatementPreparer,
  • HQLQueryPlan
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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