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


    verify(tx).commit();
  }

  @Test
  public void testTransactionCommitWithEntityInterceptor() throws Exception {
    Interceptor entityInterceptor = mock(Interceptor.class);
    Connection con = mock(Connection.class);
    final SessionFactory sf = mock(SessionFactory.class);
    Session session = mock(Session.class);
    Transaction tx = mock(Transaction.class);
View Full Code Here

    verify(tx).commit();
  }

  @Test
  public void testTransactionCommitWithEntityInterceptorBeanName() throws Exception {
    Interceptor entityInterceptor = mock(Interceptor.class);
    Interceptor entityInterceptor2 = mock(Interceptor.class);
    Connection con = mock(Connection.class);
    final SessionFactory sf = mock(SessionFactory.class);
    Session session = mock(Session.class);
    Transaction tx = mock(Transaction.class);
View Full Code Here

    Session session = null;

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

    verify(tx).commit();
  }

  @Test
  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);
View Full Code Here

    verify(tx).commit();
  }

  @Test
  public void testTransactionCommitWithEntityInterceptorBeanName() throws Exception {
    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);
View Full Code Here

        };
      }
    };
    sfb.setMappingResources(new String[0]);
    sfb.setDataSource(new DriverManagerDataSource());
    Interceptor entityInterceptor = mock(Interceptor.class);
    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

    verify(session).close();
  }

  @Test
  public void testExecuteWithThreadBoundAndNewSessionAndEntityInterceptor() throws HibernateException {
    Interceptor entityInterceptor = mock(Interceptor.class);
    Connection con = mock(Connection.class);
    Session session2 = mock(Session.class);
    given(session2.connection()).willReturn(con);
    given(sessionFactory.openSession(con, entityInterceptor)).willReturn(session);
    hibernateTemplate.setAlwaysUseNewSession(true);
View Full Code Here

    verify(session).close();
  }

  @Test
  public void testExecuteWithEntityInterceptor() throws HibernateException {
    Interceptor entityInterceptor = mock(Interceptor.class);
    given(sessionFactory.openSession(entityInterceptor)).willReturn(session);
    hibernateTemplate.setEntityInterceptor(entityInterceptor);
    final List l = new ArrayList();
    l.add("test");
    List result = hibernateTemplate.executeFind(new HibernateCallback<Object>() {
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

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.