Package org.hibernate

Examples of org.hibernate.Interceptor


    Session session = null;

    try {
      if (txObject.getSessionHolder() == null || txObject.getSessionHolder().isSynchronizedWithTransaction()) {
        Interceptor entityInterceptor = getEntityInterceptor();
        Session newSession = (entityInterceptor != null ?
            getSessionFactory().openSession(entityInterceptor) : getSessionFactory().openSession());
        if (logger.isDebugEnabled()) {
          logger.debug("Opened new Session [" + SessionFactoryUtils.toString(newSession) +
              "] for Hibernate transaction");
View Full Code Here


      }
    };
    sfb.setMappingResources(new String[0]);
    sfb.setDataSource(new DriverManagerDataSource());
    MockControl interceptorControl = MockControl.createControl(Interceptor.class);
    Interceptor entityInterceptor = (Interceptor) interceptorControl.getMock();
    interceptorControl.replay();
    sfb.setEntityInterceptor(entityInterceptor);
    try {
      sfb.afterPropertiesSet();
      fail("Should have thrown IllegalArgumentException");
    }
    catch (IllegalArgumentException ex) {
      // expected
      assertTrue("Correct exception", ex.getMessage().equals(entityInterceptor.toString()));
    }
  }
View Full Code Here

    txControl.verify();
  }

  public void testTransactionCommitWithEntityInterceptor() throws Exception {
    MockControl interceptorControl = MockControl.createControl(org.hibernate.Interceptor.class);
    Interceptor entityInterceptor = (Interceptor) interceptorControl.getMock();
    interceptorControl.replay();
    MockControl conControl = MockControl.createControl(Connection.class);
    Connection con = (Connection) conControl.getMock();
    MockControl sfControl = MockControl.createControl(SessionFactory.class);
    final SessionFactory sf = (SessionFactory) sfControl.getMock();
View Full Code Here

    conControl.verify();
  }

  public void testTransactionCommitWithEntityInterceptorBeanName() throws Exception {
    MockControl interceptorControl = MockControl.createControl(org.hibernate.Interceptor.class);
    Interceptor entityInterceptor = (Interceptor) interceptorControl.getMock();
    interceptorControl.replay();
    MockControl interceptor2Control = MockControl.createControl(org.hibernate.Interceptor.class);
    Interceptor entityInterceptor2 = (Interceptor) interceptor2Control.getMock();
    interceptor2Control.replay();

    MockControl conControl = MockControl.createControl(Connection.class);
    Connection con = (Connection) conControl.getMock();
    MockControl sfControl = MockControl.createControl(SessionFactory.class);
View Full Code Here

    }
  }

  public void testExecuteWithThreadBoundAndNewSessionAndEntityInterceptor() throws HibernateException {
    MockControl interceptorControl = MockControl.createControl(org.hibernate.Interceptor.class);
    Interceptor entityInterceptor = (Interceptor) interceptorControl.getMock();

    MockControl conControl = MockControl.createControl(Connection.class);
    Connection con = (Connection) conControl.getMock();
    MockControl session2Control = MockControl.createControl(Session.class);
    Session session2 = (Session) session2Control.getMock();
View Full Code Here

    }
  }

  public void testExecuteWithEntityInterceptor() throws HibernateException {
    MockControl interceptorControl = MockControl.createControl(org.hibernate.Interceptor.class);
    Interceptor entityInterceptor = (Interceptor) interceptorControl.getMock();

    sf.openSession(entityInterceptor);
    sfControl.setReturnValue(session, 1);
    session.getSessionFactory();
    sessionControl.setReturnValue(sf, 1);
View Full Code Here

    Session session = null;

    try {
      if (txObject.getSessionHolder() == null || txObject.getSessionHolder().isSynchronizedWithTransaction()) {
        Interceptor entityInterceptor = getEntityInterceptor();
        Session newSession = (entityInterceptor != null ?
            getSessionFactory().openSession(entityInterceptor) : getSessionFactory().openSession());
        if (logger.isDebugEnabled()) {
          logger.debug("Opened new Session [" + SessionFactoryUtils.toString(newSession) +
              "] for Hibernate transaction");
View Full Code Here

    //processes specific properties
    List<String> jaccKeys = new ArrayList<String>();


    Interceptor defaultInterceptor = DEFAULT_CONFIGURATION.getInterceptor();
    NamingStrategy defaultNamingStrategy = DEFAULT_CONFIGURATION.getNamingStrategy();

    Iterator propertyIt = preparedProperties.keySet().iterator();
    while ( propertyIt.hasNext() ) {
      Object uncastObject = propertyIt.next();
View Full Code Here

    //processes specific properties
    List<String> jaccKeys = new ArrayList<String>();


    Interceptor defaultInterceptor = DEFAULT_CONFIGURATION.getInterceptor();
    NamingStrategy defaultNamingStrategy = DEFAULT_CONFIGURATION.getNamingStrategy();

    Iterator propertyIt = preparedProperties.keySet().iterator();
    while ( propertyIt.hasNext() ) {
      Object uncastObject = propertyIt.next();
      //had to be safe
      if ( uncastObject != null && uncastObject instanceof String ) {
        String propertyKey = (String) uncastObject;
        if ( propertyKey.startsWith( AvailableSettings.CLASS_CACHE_PREFIX ) ) {
          setCacheStrategy( propertyKey, preparedProperties, true, workingVars );
        }
        else if ( propertyKey.startsWith( AvailableSettings.COLLECTION_CACHE_PREFIX ) ) {
          setCacheStrategy( propertyKey, preparedProperties, false, workingVars );
        }
        else if ( propertyKey.startsWith( AvailableSettings.JACC_PREFIX )
            && ! ( propertyKey.equals( AvailableSettings.JACC_CONTEXT_ID )
            || propertyKey.equals( AvailableSettings.JACC_ENABLED ) ) ) {
          jaccKeys.add( propertyKey );
        }
      }
    }
    final Interceptor interceptor = instantiateCustomClassFromConfiguration(
        preparedProperties,
        defaultInterceptor,
        cfg.getInterceptor(),
        AvailableSettings.INTERCEPTOR,
        "interceptor",
View Full Code Here

    if ( session == null ) {
      SessionBuilderImplementor sessionBuilder = internalGetEntityManagerFactory().getSessionFactory().withOptions();
      sessionBuilder.owner( this );
      if (sessionInterceptorClass != null) {
        try {
          Interceptor interceptor = (Interceptor) sessionInterceptorClass.newInstance();
          sessionBuilder.interceptor( interceptor );
        }
        catch (InstantiationException e) {
          throw new PersistenceException("Unable to instantiate session interceptor: " + sessionInterceptorClass, e);
        }
View Full Code Here

TOP

Related Classes of org.hibernate.Interceptor

Copyright © 2018 www.massapicom. 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.