org.hibernate.engine.spi.SessionImplementor

Here are the examples of the java api org.hibernate.engine.spi.SessionImplementor taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

148 Examples 7

19 Source : PostgreSQLEnumType.java
with Apache License 2.0
from vladmihalcea

public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
    st.setObject(index, value != null ? ((Enum) value).name() : null, Types.OTHER);
}

19 Source : SessionStatisticsImpl.java
with GNU General Public License v2.0
from lamsfoundation

/**
 * @author Gavin King
 */
public clreplaced SessionStatisticsImpl implements SessionStatistics {

    private final SessionImplementor session;

    public SessionStatisticsImpl(SessionImplementor session) {
        this.session = session;
    }

    public int getEnreplacedyCount() {
        return session.getPersistenceContext().getNumberOfManagedEnreplacedies();
    }

    public int getCollectionCount() {
        return session.getPersistenceContext().getCollectionEntries().size();
    }

    public Set getEnreplacedyKeys() {
        return Collections.unmodifiableSet(session.getPersistenceContext().getEnreplacediesByKey().keySet());
    }

    public Set getCollectionKeys() {
        return Collections.unmodifiableSet(session.getPersistenceContext().getCollectionsByKey().keySet());
    }

    public String toString() {
        return new StringBuilder().append("SessionStatistics[").append("enreplacedy count=").append(getEnreplacedyCount()).append(",collection count=").append(getCollectionCount()).append(']').toString();
    }
}

19 Source : CriteriaCompiler.java
with GNU General Public License v2.0
from lamsfoundation

/**
 * Compiles a JPA criteria query into an executable {@link TypedQuery}.  Its single contract is the {@link #compile}
 * method.
 * <p/>
 * NOTE : This is a temporary implementation which simply translates the criteria query into a JPAQL query string.  A
 * better, long-term solution is being implemented as part of refactoring the JPAQL/HQL translator.
 *
 * @author Steve Ebersole
 */
public clreplaced CriteriaCompiler implements Serializable {

    private final SessionImplementor enreplacedyManager;

    public CriteriaCompiler(SessionImplementor enreplacedyManager) {
        this.enreplacedyManager = enreplacedyManager;
    }

    public QueryImplementor compile(CompilableCriteria criteria) {
        try {
            criteria.validate();
        } catch (IllegalStateException ise) {
            throw new IllegalArgumentException("Error occurred validating the Criteria", ise);
        }
        final Map<ParameterExpression<?>, ExplicitParameterInfo<?>> explicitParameterInfoMap = new HashMap<>();
        final List<ImplicitParameterBinding> implicitParameterBindings = new ArrayList<>();
        final SessionFactoryImplementor sessionFactory = enreplacedyManager.getSessionFactory();
        final LiteralHandlingMode criteriaLiteralHandlingMode = sessionFactory.getSessionFactoryOptions().getCriteriaLiteralHandlingMode();
        final Dialect dialect = sessionFactory.getServiceRegistry().getService(JdbcServices.clreplaced).getDialect();
        RenderingContext renderingContext = new RenderingContext() {

            private int aliasCount;

            private int explicitParameterCount;

            public String generateAlias() {
                return "generatedAlias" + aliasCount++;
            }

            public String generateParameterName() {
                return "param" + explicitParameterCount++;
            }

            @Override
            @SuppressWarnings("unchecked")
            public ExplicitParameterInfo registerExplicitParameter(ParameterExpression<?> criteriaQueryParameter) {
                ExplicitParameterInfo parameterInfo = explicitParameterInfoMap.get(criteriaQueryParameter);
                if (parameterInfo == null) {
                    if (StringHelper.isNotEmpty(criteriaQueryParameter.getName())) {
                        parameterInfo = new ExplicitParameterInfo(criteriaQueryParameter.getName(), null, criteriaQueryParameter.getJavaType());
                    } else if (criteriaQueryParameter.getPosition() != null) {
                        parameterInfo = new ExplicitParameterInfo(null, criteriaQueryParameter.getPosition(), criteriaQueryParameter.getJavaType());
                    } else {
                        parameterInfo = new ExplicitParameterInfo(generateParameterName(), null, criteriaQueryParameter.getJavaType());
                    }
                    explicitParameterInfoMap.put(criteriaQueryParameter, parameterInfo);
                }
                return parameterInfo;
            }

            public String registerLiteralParameterBinding(final Object literal, final Clreplaced javaType) {
                final String parameterName = generateParameterName();
                final ImplicitParameterBinding binding = new ImplicitParameterBinding() {

                    public String getParameterName() {
                        return parameterName;
                    }

                    public Clreplaced getJavaType() {
                        return javaType;
                    }

                    public void bind(TypedQuery typedQuery) {
                        typedQuery.setParameter(parameterName, literal);
                    }
                };
                implicitParameterBindings.add(binding);
                return parameterName;
            }

            public String getCastType(Clreplaced javaType) {
                SessionFactoryImplementor factory = enreplacedyManager.getFactory();
                Type hibernateType = factory.getTypeResolver().heuristicType(javaType.getName());
                if (hibernateType == null) {
                    throw new IllegalArgumentException("Could not convert java type [" + javaType.getName() + "] to Hibernate type");
                }
                return hibernateType.getName();
            }

            @Override
            public Dialect getDialect() {
                return dialect;
            }

            @Override
            public LiteralHandlingMode getCriteriaLiteralHandlingMode() {
                return criteriaLiteralHandlingMode;
            }
        };
        return criteria.interpret(renderingContext).buildCompiledQuery(enreplacedyManager, new InterpretedParameterMetadata() {

            @Override
            public Map<ParameterExpression<?>, ExplicitParameterInfo<?>> explicitParameterInfoMap() {
                return explicitParameterInfoMap;
            }

            @Override
            public List<ImplicitParameterBinding> implicitParameterBindings() {
                return implicitParameterBindings;
            }
        });
    }
}

19 Source : DefaultSaveEventListener.java
with GNU General Public License v2.0
from lamsfoundation

protected boolean rereplacedociateIfUninitializedProxy(Object object, SessionImplementor source) {
    if (!Hibernate.isInitialized(object)) {
        throw new PersistentObjectException("uninitialized proxy preplaceded to save()");
    } else {
        return false;
    }
}

18 Source : SnowflakeIdWorker.java
with MIT License
from yupaits

@Override
public Serializable generate(SessionImplementor sessionImplementor, Object o) throws HibernateException {
    return nextId();
}

18 Source : ImmutableType.java
with Apache License 2.0
from vladmihalcea

@Override
public Object resolve(Object value, SessionImplementor session, Object owner) throws HibernateException {
    return value;
}

18 Source : ImmutableType.java
with Apache License 2.0
from vladmihalcea

@Override
public final boolean isDirty(Object old, Object current, boolean[] checkable, SessionImplementor session) {
    return checkable[0] && isDirty(old, current);
}

18 Source : ImmutableType.java
with Apache License 2.0
from vladmihalcea

@Override
public Serializable disreplacedemble(Object value, SessionImplementor session, Object owner) throws HibernateException {
    return disreplacedemble(value);
}

18 Source : ImmutableType.java
with Apache License 2.0
from vladmihalcea

@Override
public Object semiResolve(Object value, SessionImplementor session, Object owner) throws HibernateException {
    return value;
}

18 Source : ImmutableType.java
with Apache License 2.0
from vladmihalcea

@Override
public Object replacedemble(Serializable cached, SessionImplementor session, Object owner) throws HibernateException {
    return replacedemble(cached, session);
}

18 Source : ImmutableType.java
with Apache License 2.0
from vladmihalcea

@Override
public final boolean isDirty(Object old, Object current, SessionImplementor session) {
    return isDirty(old, current);
}

18 Source : ImmutableType.java
with Apache License 2.0
from vladmihalcea

@Override
public boolean isModified(Object dbState, Object currentState, boolean[] checkable, SessionImplementor session) throws HibernateException {
    return isDirty(dbState, currentState);
}

18 Source : ImmutableType.java
with Apache License 2.0
from vladmihalcea

@Override
public void beforereplacedemble(Serializable cached, SessionImplementor session) {
}

18 Source : ImmutableType.java
with Apache License 2.0
from vladmihalcea

@Override
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws SQLException {
    set(st, clazz.cast(value), index, session);
}

18 Source : ImmutableType.java
with Apache License 2.0
from vladmihalcea

@Override
public void nullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, SessionImplementor session) throws HibernateException, SQLException {
    set(st, returnedClreplaced().cast(value), index, session);
}

18 Source : PostgreSQLCITextType.java
with Apache License 2.0
from vladmihalcea

@Override
protected void set(PreparedStatement st, String value, int index, SessionImplementor session) throws SQLException {
    st.setObject(index, value, Types.OTHER);
}

18 Source : ContainerOidGenerator.java
with Apache License 2.0
from Pardus-Engerek

@Override
public Serializable generate(SessionImplementor session, Object object) throws HibernateException {
    return generate(object);
}

18 Source : ContainerIdGenerator.java
with Apache License 2.0
from Pardus-Engerek

@Override
public Serializable generate(SessionImplementor session, Object object) throws HibernateException {
    if (object instanceof Container) {
        return generate((Container) object);
    } else if (object instanceof L2Container) {
        return generate((L2Container) object);
    } else {
        throw new HibernateException("Couldn't create id for '" + object.getClreplaced().getSimpleName() + "' not instance of '" + Container.clreplaced.getName() + "'.");
    }
}

18 Source : CertWorkItemIdGenerator.java
with Apache License 2.0
from Pardus-Engerek

@Override
public Serializable generate(SessionImplementor session, Object object) throws HibernateException {
    if (object instanceof RAccessCertificationWorkItem) {
        return generate((RAccessCertificationWorkItem) object);
    } else {
        throw new HibernateException("Couldn't create id for '" + object.getClreplaced().getSimpleName() + "' not instance of '" + RAccessCertificationWorkItem.clreplaced.getName() + "'.");
    }
}

18 Source : PrefixedStringType.java
with Apache License 2.0
from Pardus-Engerek

@Override
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
    if (isOracle(session) && value != null) {
        value = '\u0000' + ((String) value);
    }
    StringType.INSTANCE.nullSafeSet(st, value, index, session);
}

18 Source : MoneyType.java
with GNU Lesser General Public License v3.0
from ozguryazilimas

@Override
public void nullSafeSet(PreparedStatement ps, Object o, int i, SessionImplementor si) throws HibernateException, SQLException {
    if (o == null) {
        BigDecimalType.INSTANCE.nullSafeSet(ps, null, i, si);
        StringType.INSTANCE.nullSafeSet(ps, null, i + 1, si);
    } else {
        MonetaryAmount q = (MonetaryAmount) o;
        BigDecimalType.INSTANCE.nullSafeSet(ps, new BigDecimal(q.getNumber().toString()), i, si);
        StringType.INSTANCE.nullSafeSet(ps, q.getCurrency().getCurrencyCode(), i + 1, si);
    }
}

18 Source : ManagedFlushCheckerLegacyJpaImpl.java
with GNU General Public License v2.0
from lamsfoundation

@Override
public boolean shouldDoManagedFlush(SessionImplementor session) {
    return !session.isClosed() && session.getHibernateFlushMode() == FlushMode.MANUAL;
}

18 Source : ExceptionMapperStandardImpl.java
with GNU General Public License v2.0
from lamsfoundation

@Override
public RuntimeException mapManagedFlushFailure(String message, RuntimeException failure, SessionImplementor session) {
    log.unableToPerformManagedFlush(failure.getMessage());
    return failure;
}

18 Source : Hibernate.java
with GNU General Public License v2.0
from lamsfoundation

/**
 * Obtain a lob creator for the given session.
 *
 * @param session The session for which to obtain a lob creator
 *
 * @return The log creator reference
 */
public static LobCreator getLobCreator(SessionImplementor session) {
    return session.getFactory().getServiceRegistry().getService(JdbcServices.clreplaced).getLobCreator(session);
}

18 Source : DefaultSaveOrUpdateEventListener.java
with GNU General Public License v2.0
from lamsfoundation

protected boolean rereplacedociateIfUninitializedProxy(Object object, SessionImplementor source) {
    return source.getPersistenceContext().rereplacedociateIfUninitializedProxy(object);
}

18 Source : DefaultFlushEntityEventListener.java
with GNU General Public License v2.0
from lamsfoundation

private void checkNaturalId(EnreplacedyPersister persister, EnreplacedyEntry entry, Object[] current, Object[] loaded, SessionImplementor session) {
    if (persister.hasNaturalIdentifier() && entry.getStatus() != Status.READ_ONLY) {
        if (!persister.getEnreplacedyMetamodel().hasImmutableNaturalId()) {
            // SHORT-CUT: if the natural id is mutable (!immutable), no need to do the below checks
            // EARLY EXIT!!!
            return;
        }
        final int[] naturalIdentifierPropertiesIndexes = persister.getNaturalIdentifierProperties();
        final Type[] propertyTypes = persister.getPropertyTypes();
        final boolean[] propertyUpdateability = persister.getPropertyUpdateability();
        final Object[] snapshot = loaded == null ? session.getPersistenceContext().getNaturalIdSnapshot(entry.getId(), persister) : session.getPersistenceContext().getNaturalIdHelper().extractNaturalIdValues(loaded, persister);
        for (int i = 0; i < naturalIdentifierPropertiesIndexes.length; i++) {
            final int naturalIdentifierPropertyIndex = naturalIdentifierPropertiesIndexes[i];
            if (propertyUpdateability[naturalIdentifierPropertyIndex]) {
                // if the given natural id property is updatable (mutable), there is nothing to check
                continue;
            }
            final Type propertyType = propertyTypes[naturalIdentifierPropertyIndex];
            if (!propertyType.isEqual(current[naturalIdentifierPropertyIndex], snapshot[i])) {
                throw new HibernateException(String.format("An immutable natural identifier of enreplacedy %s was altered from %s to %s", persister.getEnreplacedyName(), propertyTypes[naturalIdentifierPropertyIndex].toLoggableString(snapshot[i], session.getFactory()), propertyTypes[naturalIdentifierPropertyIndex].toLoggableString(current[naturalIdentifierPropertyIndex], session.getFactory())));
            }
        }
    }
}

18 Source : DefaultFlushEntityEventListener.java
with GNU General Public License v2.0
from lamsfoundation

protected boolean invokeInterceptor(SessionImplementor session, Object enreplacedy, EnreplacedyEntry entry, final Object[] values, EnreplacedyPersister persister) {
    boolean isDirty = false;
    if (entry.getStatus() != Status.DELETED) {
        if (callbackRegistry.preUpdate(enreplacedy)) {
            isDirty = copyState(enreplacedy, persister.getPropertyTypes(), values, session.getFactory());
        }
    }
    final boolean answerFromInterceptor = session.getInterceptor().onFlushDirty(enreplacedy, entry.getId(), values, entry.getLoadedState(), persister.getPropertyNames(), persister.getPropertyTypes());
    return answerFromInterceptor || isDirty;
}

18 Source : AbstractFlushingEventListener.java
with GNU General Public License v2.0
from lamsfoundation

protected void postPostFlush(SessionImplementor session) {
    session.getInterceptor().postFlush(new LazyIterator(session.getPersistenceContext().getEnreplacediesByKey()));
}

18 Source : ParameterBinder.java
with GNU General Public License v2.0
from lamsfoundation

private static int bindPositionalParameters(final PreparedStatement st, final Object[] values, final Type[] types, final int start, final SessionImplementor session) throws SQLException, HibernateException {
    int span = 0;
    for (int i = 0; i < values.length; i++) {
        types[i].nullSafeSet(st, values[i], start + span, session);
        span += types[i].getColumnSpan(session.getFactory());
    }
    return span;
}

18 Source : Collections.java
with GNU General Public License v2.0
from lamsfoundation

/**
 * record the fact that this collection was dereferenced
 *
 * @param coll The collection to be updated by un-reachability.
 * @param session The session
 */
public static void processUnreachableCollection(PersistentCollection coll, SessionImplementor session) {
    if (coll.getOwner() == null) {
        processNeverReferencedCollection(coll, session);
    } else {
        processDereferencedCollection(coll, session);
    }
}

18 Source : IDSequenceGenerator.java
with Apache License 2.0
from izern

@Override
public Serializable generate(SessionImplementor arg0, Object arg1) throws HibernateException {
    return sequence.nextId();
}

18 Source : ReactiveDynamicBatchingEntityLoader.java
with GNU Lesser General Public License v2.1
from hibernate

public CompletionStage<List<Object>> doEnreplacedyBatchFetch(SessionImplementor session, QueryParameters queryParameters, Serializable[] ids) {
    final String sql = expandBatchIdPlaceholder(sqlTemplate, ids, alias, persister.getKeyColumnNames(), getDialect());
    // Filters might add additional parameters and our processor is not smart enough, right now, to
    // recognize them if the query has been processed already.
    // So we only process the SQL in advance if filters are disabled.
    final String processedSQL = session.getLoadQueryInfluencers().hasEnabledFilters() ? sql : parameters().process(sql);
    return doReactiveQueryAndInitializeNonLazyCollections(processedSQL, session, queryParameters).handle((results, err) -> {
        logSqlException(err, () -> "could not load an enreplacedy batch: " + infoString(getEnreplacedyPersisters()[0], ids, session.getFactory()), sql);
        return returnOrRethrow(err, results);
    });
}

18 Source : ReactiveAbstractEntityLoader.java
with GNU Lesser General Public License v2.1
from hibernate

protected CompletionStage<List<Object>> doReactiveQueryAndInitializeNonLazyCollections(final SessionImplementor session, final QueryParameters queryParameters, final boolean returnProxies) {
    return doReactiveQueryAndInitializeNonLazyCollections(getSQLString(), session, queryParameters, returnProxies, null);
}

18 Source : ForeignKeys.java
with GNU Lesser General Public License v2.1
from hibernate

/**
 * Is this instance persistent or detached?
 * <p/>
 * If <tt>replacedumed</tt> is non-null, don't hit the database to make the determination, instead replacedume that
 * value; the client code must be prepared to "recover" in the case that this replacedumed result is incorrect.
 *
 * @param enreplacedyName The name of the enreplacedy
 * @param enreplacedy The enreplacedy instance
 * @param replacedumed The replacedumed return value, if avoiding database hit is desired
 * @param session The session
 *
 * @return {@code true} if the given enreplacedy is not transient (meaning it is either detached/persistent)
 */
@SuppressWarnings("SimplifiableIfStatement")
public static CompletionStage<Boolean> isNotTransient(String enreplacedyName, Object enreplacedy, Boolean replacedumed, SessionImplementor session) {
    if (enreplacedy instanceof HibernateProxy) {
        return trueFuture();
    }
    if (session.getPersistenceContextInternal().isEntryFor(enreplacedy)) {
        return trueFuture();
    }
    // todo : shouldnt replacedumed be revered here?
    return isTransient(enreplacedyName, enreplacedy, replacedumed, session).thenApply(trans -> !trans);
}

18 Source : BaseCoreFunctionalTestCase.java
with GNU Lesser General Public License v2.1
from GoogleCloudPlatform

protected void inTransaction(SessionImplementor session, Consumer<SessionImplementor> action) {
    TransactionUtil2.inTransaction(session, action);
}

18 Source : TimestampToString.java
with Apache License 2.0
from exactpro

@Override
public void nullSafeSet(PreparedStatement ps, Object value, int index, SessionImplementor s) throws HibernateException, SQLException {
    StringType.INSTANCE.set(ps, value == null ? "" : dateToString((Date) value), index, s);
}

18 Source : TimestampToLong.java
with Apache License 2.0
from exactpro

@Override
public void nullSafeSet(PreparedStatement ps, Object value, int index, SessionImplementor s) throws HibernateException, SQLException {
    LongType.INSTANCE.set(ps, value == null ? 0L : ((Date) value).getTime(), index, s);
}

17 Source : ImmutableType.java
with Apache License 2.0
from vladmihalcea

@Override
public Object nullSafeGet(ResultSet rs, String name, SessionImplementor session, Object owner) throws HibernateException, SQLException {
    return get(rs, new String[] { name }, session, owner);
}

17 Source : ImmutableType.java
with Apache License 2.0
from vladmihalcea

@Override
public Object replace(Object original, Object target, SessionImplementor session, Object owner, Map copyCache, ForeignKeyDirection foreignKeyDirection) throws HibernateException {
    return replace(original, target, owner);
}

17 Source : ImmutableType.java
with Apache License 2.0
from vladmihalcea

@Override
public Object hydrate(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
    return nullSafeGet(rs, names, session, owner);
}

17 Source : ImmutableType.java
with Apache License 2.0
from vladmihalcea

@Override
public Object replace(Object original, Object target, SessionImplementor session, Object owner, Map copyCache) throws HibernateException {
    return replace(original, target, owner);
}

17 Source : ImmutableType.java
with Apache License 2.0
from vladmihalcea

/* Methods inherited from the {@link UserType} interface */
@Override
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException {
    return get(rs, names, session, owner);
}

17 Source : PostgreSQLHStoreType.java
with Apache License 2.0
from vladmihalcea

@Override
protected Map get(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException {
    return (Map) rs.getObject(names[0]);
}

17 Source : PostgreSQLHStoreType.java
with Apache License 2.0
from vladmihalcea

@Override
protected void set(PreparedStatement st, Map value, int index, SessionImplementor session) throws SQLException {
    st.setObject(index, value);
}

17 Source : XMLType.java
with MIT License
from rp-consulting

@Override
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
    if (value == null) {
        st.setNull(index, Types.OTHER);
    } else {
        st.setObject(index, value, Types.OTHER);
    }
}

17 Source : PrefixedStringType.java
with Apache License 2.0
from Pardus-Engerek

@Override
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
    String value = StringType.INSTANCE.nullSafeGet(rs, names[0], session);
    if (isOracle(session) && value != null) {
        value = value.substring(1);
    }
    return value;
}

17 Source : PrefixedStringType.java
with Apache License 2.0
from Pardus-Engerek

private boolean isOracle(SessionImplementor session) {
    SessionFactoryImplementor factory = session.getFactory();
    // System.out.println("]]] " + Oracle10gDialect.clreplaced.isreplacedignableFrom(factory.getDialect().getClreplaced()));
    return Oracle10gDialect.clreplaced.isreplacedignableFrom(factory.getDialect().getClreplaced());
}

17 Source : QuantityType.java
with GNU Lesser General Public License v3.0
from ozguryazilimas

@Override
public void nullSafeSet(PreparedStatement ps, Object value, int i, SessionImplementor si) throws HibernateException, SQLException {
    if (value == null) {
        BigDecimalType.INSTANCE.nullSafeSet(ps, null, i, si);
        StringType.INSTANCE.nullSafeSet(ps, null, i + 1, si);
    } else {
        QuanreplacedativeAmount q = (QuanreplacedativeAmount) value;
        BigDecimalType.INSTANCE.nullSafeSet(ps, q.getAmount(), i, si);
        StringType.INSTANCE.nullSafeSet(ps, q.getUnitName().toString(), i + 1, si);
    }
}

17 Source : SpringHibernateTransactionOperations.java
with Apache License 2.0
from micronaut-projects

@NonNull
@Override
public Connection getConnection() {
    final SessionImplementor session = (SessionImplementor) sessionFactory.getCurrentSession();
    return session.connection();
}

17 Source : AbstractJaccSecurableEventListener.java
with GNU General Public License v2.0
from lamsfoundation

protected void performSecurityCheck(SessionImplementor session, PermissionCheckEnreplacedyInformation enreplacedyInformation, PermissibleAction action) {
    if (jaccService == null) {
        jaccService = session.getFactory().getServiceRegistry().getService(JaccService.clreplaced);
    }
    jaccService.checkPermission(enreplacedyInformation, action);
}

See More Examples