Examples of SessionBuilder


Examples of com.facebook.presto.Session.SessionBuilder

    {
    }

    public static Session createSessionForRequest(HttpServletRequest servletRequest)
    {
        SessionBuilder sessionBuilder = Session.builder()
                .setUser(getRequiredHeader(servletRequest, PRESTO_USER, "User"))
                .setSource(servletRequest.getHeader(PRESTO_SOURCE))
                .setCatalog(getRequiredHeader(servletRequest, PRESTO_CATALOG, "Catalog"))
                .setSchema(getRequiredHeader(servletRequest, PRESTO_SCHEMA, "Schema"))
                .setRemoteUserAddress(servletRequest.getRemoteAddr())
                .setUserAgent(servletRequest.getHeader(USER_AGENT));

        String timeZoneId = servletRequest.getHeader(PRESTO_TIME_ZONE);
        if (timeZoneId != null) {
            sessionBuilder.setTimeZoneKey(getTimeZoneKey(timeZoneId));
        }

        String language = servletRequest.getHeader(PRESTO_LANGUAGE);
        if (language != null) {
            sessionBuilder.setLocale(Locale.forLanguageTag(language));
        }

        return sessionBuilder.build();
    }
View Full Code Here

Examples of org.hibernate.SessionBuilder

  public SessionFactoryImplementor factory() {
    return factory;
  }

  protected SessionBuilder baseSessionBuilder() {
    final SessionBuilder builder = factory.withOptions();
    final CurrentTenantIdentifierResolver resolver = factory.getCurrentTenantIdentifierResolver();
    if ( resolver != null ) {
      builder.tenantIdentifier( resolver.resolveCurrentTenantIdentifier() );
    }
    return builder;
  }
View Full Code Here

Examples of org.hibernate.SessionBuilder

  }

  @Override
    protected Session getRawSession() {
    if ( session == null ) {
      SessionBuilder sessionBuilder = getEntityManagerFactory().getSessionFactory().withOptions();
      if (sessionInterceptorClass != null) {
        try {
          Interceptor interceptor = (Interceptor) sessionInterceptorClass.newInstance();
          sessionBuilder.interceptor( interceptor );
        }
        catch (InstantiationException e) {
          throw new PersistenceException("Unable to instanciate session interceptor: " + sessionInterceptorClass, e);
        }
        catch (IllegalAccessException e) {
          throw new PersistenceException("Unable to instanciate session interceptor: " + sessionInterceptorClass, e);
        }
        catch (ClassCastException e) {
          throw new PersistenceException("Session interceptor does not implement Interceptor: " + sessionInterceptorClass, e);
        }
      }
      sessionBuilder.autoJoinTransactions( getTransactionType() != PersistenceUnitTransactionType.JTA );
      session = sessionBuilder.openSession();
      if ( persistenceContextType == PersistenceContextType.TRANSACTION ) {
        ( (SessionImplementor) session ).setAutoClear( true );
      }
    }
    return session;
View Full Code Here

Examples of org.hibernate.SessionBuilder

  }

  @Override
    protected Session getRawSession() {
    if ( session == null ) {
      SessionBuilder sessionBuilder = getEntityManagerFactory().getSessionFactory().withOptions();
      if (sessionInterceptorClass != null) {
        try {
          Interceptor interceptor = (Interceptor) sessionInterceptorClass.newInstance();
          sessionBuilder.interceptor( interceptor );
        }
        catch (InstantiationException e) {
          throw new PersistenceException("Unable to instanciate session interceptor: " + sessionInterceptorClass, e);
        }
        catch (IllegalAccessException e) {
          throw new PersistenceException("Unable to instanciate session interceptor: " + sessionInterceptorClass, e);
        }
        catch (ClassCastException e) {
          throw new PersistenceException("Session interceptor does not implement Interceptor: " + sessionInterceptorClass, e);
        }
      }
      sessionBuilder.autoJoinTransactions( getTransactionType() != PersistenceUnitTransactionType.JTA );
      session = sessionBuilder.openSession();
      if ( persistenceContextType == PersistenceContextType.TRANSACTION ) {
        ( (SessionImplementor) session ).setAutoClear( true );
      }
    }
    return session;
View Full Code Here

Examples of org.hibernate.SessionBuilder

  public SessionFactoryImplementor factory() {
    return factory;
  }

  protected SessionBuilder baseSessionBuilder() {
    final SessionBuilder builder = factory.withOptions();
    final CurrentTenantIdentifierResolver resolver = factory.getCurrentTenantIdentifierResolver();
    if ( resolver != null ) {
      builder.tenantIdentifier( resolver.resolveCurrentTenantIdentifier() );
    }
    return builder;
  }
View Full Code Here

Examples of org.hibernate.SessionBuilder

  }

  @Override
    protected Session getRawSession() {
    if ( session == null ) {
      SessionBuilder sessionBuilder = getEntityManagerFactory().getSessionFactory().withOptions();
      if (sessionInterceptorClass != null) {
        try {
          Interceptor interceptor = (Interceptor) sessionInterceptorClass.newInstance();
          sessionBuilder.interceptor( interceptor );
        }
        catch (InstantiationException e) {
          throw new PersistenceException("Unable to instanciate session interceptor: " + sessionInterceptorClass, e);
        }
        catch (IllegalAccessException e) {
          throw new PersistenceException("Unable to instanciate session interceptor: " + sessionInterceptorClass, e);
        }
        catch (ClassCastException e) {
          throw new PersistenceException("Session interceptor does not implement Interceptor: " + sessionInterceptorClass, e);
        }
      }
      sessionBuilder.autoJoinTransactions( getTransactionType() != PersistenceUnitTransactionType.JTA );
      session = sessionBuilder.openSession();
      if ( persistenceContextType == PersistenceContextType.TRANSACTION ) {
        ( (SessionImplementor) session ).setAutoClear( true );
      }
    }
    return session;
View Full Code Here

Examples of org.hibernate.SessionBuilder

  public void testTransactionCommitWithEntityInterceptor() throws Exception {
    Interceptor entityInterceptor = mock(Interceptor.class);
    Connection con = mock(Connection.class);
    final SessionFactory sf = mock(SessionFactory.class);
    ImplementingSession session = mock(ImplementingSession.class);
    SessionBuilder options = mock(SessionBuilder.class);
    Transaction tx = mock(Transaction.class);

    given(sf.withOptions()).willReturn(options);
    given(options.interceptor(entityInterceptor)).willReturn(options);
    given(options.openSession()).willReturn(session);
    given(session.beginTransaction()).willReturn(tx);
    given(session.isOpen()).willReturn(true);
    given(session.isConnected()).willReturn(true);
    given(session.connection()).willReturn(con);
View Full Code Here

Examples of org.hibernate.SessionBuilder

    Interceptor entityInterceptor = mock(Interceptor.class);
    Interceptor entityInterceptor2 = mock(Interceptor.class);
    Connection con = mock(Connection.class);
    final SessionFactory sf = mock(SessionFactory.class);
    ImplementingSession session = mock(ImplementingSession.class);
    SessionBuilder options = mock(SessionBuilder.class);
    Transaction tx = mock(Transaction.class);

    given(sf.withOptions()).willReturn(options);
    given(options.interceptor(entityInterceptor)).willReturn(options);
    given(options.interceptor(entityInterceptor2)).willReturn(options);
    given(options.openSession()).willReturn(session);
    given(session.beginTransaction()).willReturn(tx);
    given(session.isOpen()).willReturn(true);
    given(session.isConnected()).willReturn(true);
    given(session.connection()).willReturn(con);
View Full Code Here

Examples of org.hibernate.SessionBuilder

  }

  @Override
    protected Session getRawSession() {
    if ( session == null ) {
      SessionBuilder sessionBuilder = getEntityManagerFactory().getSessionFactory().withOptions();
      if (sessionInterceptorClass != null) {
        try {
          Interceptor interceptor = (Interceptor) sessionInterceptorClass.newInstance();
          sessionBuilder.interceptor( interceptor );
        }
        catch (InstantiationException e) {
          throw new PersistenceException("Unable to instanciate session interceptor: " + sessionInterceptorClass, e);
        }
        catch (IllegalAccessException e) {
          throw new PersistenceException("Unable to instanciate session interceptor: " + sessionInterceptorClass, e);
        }
        catch (ClassCastException e) {
          throw new PersistenceException("Session interceptor does not implement Interceptor: " + sessionInterceptorClass, e);
        }
      }
      sessionBuilder.autoJoinTransactions( getTransactionType() != PersistenceUnitTransactionType.JTA );
      session = sessionBuilder.openSession();
      if ( persistenceContextType == PersistenceContextType.TRANSACTION ) {
        ( (SessionImplementor) session ).setAutoClear( true );
      }
    }
    return session;
View Full Code Here

Examples of org.menacheri.jetclient.app.impl.DefaultSession.SessionBuilder

   * @return Returns the session instance created using a
   *         {@link SessionBuilder}.
   */
  public Session createSession()
  {
    SessionBuilder sessionBuilder = new SessionBuilder().id(sessionId
        .incrementAndGet());
    return sessionBuilder.build();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.