Package org.hibernate.event

Examples of org.hibernate.event.EventListeners


  }

  public void removeLifecycle(SessionFactory sessionFactory) {

    SessionFactoryImpl sessionFactoryImpl = (SessionFactoryImpl) sessionFactory;
    EventListeners eventListeners = sessionFactoryImpl.getEventListeners();

    PostInsertEventListener[] postInsertEventListeners;
    if (registerPostCommitListeneres) {
      postInsertEventListeners = eventListeners.getPostCommitInsertEventListeners();
    } else {
      postInsertEventListeners = eventListeners.getPostInsertEventListeners();
    }
    List<PostInsertEventListener> tempPostInsertEventListeners = Lists.newArrayList();
    for (int i = 0; i < postInsertEventListeners.length; i++) {
      PostInsertEventListener postInsertEventListener = postInsertEventListeners[i];
      if (!(postInsertEventListener instanceof HibernateEventListener)) {
        tempPostInsertEventListeners.add(postInsertEventListener);
      }
    }
    if (registerPostCommitListeneres) {
      eventListeners.setPostCommitInsertEventListeners((PostInsertEventListener[]) tempPostInsertEventListeners
          .toArray(new PostInsertEventListener[tempPostInsertEventListeners.size()]));
    } else {
      eventListeners.setPostInsertEventListeners((PostInsertEventListener[]) tempPostInsertEventListeners
          .toArray(new PostInsertEventListener[tempPostInsertEventListeners.size()]));
    }

    PostUpdateEventListener[] postUpdateEventListeners;
    if (registerPostCommitListeneres) {
      postUpdateEventListeners = eventListeners.getPostCommitUpdateEventListeners();
    } else {
      postUpdateEventListeners = eventListeners.getPostUpdateEventListeners();
    }
    List<PostUpdateEventListener> tempPostUpdateEventListeners = Lists.newArrayList();
    for (int i = 0; i < postUpdateEventListeners.length; i++) {
      PostUpdateEventListener postUpdateEventListener = postUpdateEventListeners[i];
      if (!(postUpdateEventListener instanceof HibernateEventListener)) {
        tempPostUpdateEventListeners.add(postUpdateEventListener);
      }
    }
    if (registerPostCommitListeneres) {
      eventListeners.setPostCommitUpdateEventListeners((PostUpdateEventListener[]) tempPostUpdateEventListeners
          .toArray(new PostUpdateEventListener[tempPostUpdateEventListeners.size()]));
    } else {
      eventListeners.setPostUpdateEventListeners((PostUpdateEventListener[]) tempPostUpdateEventListeners
          .toArray(new PostUpdateEventListener[tempPostUpdateEventListeners.size()]));
    }

    PostDeleteEventListener[] postDeleteEventListeners;
    if (registerPostCommitListeneres) {
      postDeleteEventListeners = eventListeners.getPostCommitDeleteEventListeners();
    } else {
      postDeleteEventListeners = eventListeners.getPostDeleteEventListeners();
    }
    List<PostDeleteEventListener> tempPostDeleteEventListeners = Lists.newArrayList();
    for (int i = 0; i < postDeleteEventListeners.length; i++) {
      PostDeleteEventListener postDeleteEventListener = postDeleteEventListeners[i];
      if (!(postDeleteEventListener instanceof HibernateEventListener)) {
        tempPostDeleteEventListeners.add(postDeleteEventListener);
      }
    }
    if (registerPostCommitListeneres) {
      eventListeners.setPostCommitDeleteEventListeners((PostDeleteEventListener[]) tempPostDeleteEventListeners
          .toArray(new PostDeleteEventListener[tempPostDeleteEventListeners.size()]));
    } else {
      eventListeners.setPostDeleteEventListeners((PostDeleteEventListener[]) tempPostDeleteEventListeners
          .toArray(new PostDeleteEventListener[tempPostDeleteEventListeners.size()]));
    }

    if (registerPostCommitListeneres) {
      return;
    }

    PostCollectionRecreateEventListener[] postCollectionRecreateEventListeners = eventListeners
        .getPostCollectionRecreateEventListeners();
    List<PostCollectionRecreateEventListener> tempPostCollectionRecreateEventListeners = Lists.newArrayList();
    for (PostCollectionRecreateEventListener postCollectionRecreateEventListener : postCollectionRecreateEventListeners) {
      if (!(postCollectionRecreateEventListener instanceof HibernateEventListener)) {
        tempPostCollectionRecreateEventListeners.add(postCollectionRecreateEventListener);
      }
    }
    eventListeners.setPostCollectionRecreateEventListeners(tempPostCollectionRecreateEventListeners
        .toArray(new PostCollectionRecreateEventListener[tempPostCollectionRecreateEventListeners.size()]));

    PostCollectionUpdateEventListener[] postCollectionUpdateEventListeners = eventListeners
        .getPostCollectionUpdateEventListeners();
    List<PostCollectionUpdateEventListener> tempPostCollectionUpdateEventListeners = Lists.newArrayList();
    for (PostCollectionUpdateEventListener postCollectionUpdateEventListener : postCollectionUpdateEventListeners) {
      if (!(postCollectionUpdateEventListener instanceof HibernateEventListener)) {
        tempPostCollectionUpdateEventListeners.add(postCollectionUpdateEventListener);
      }
    }
    eventListeners.setPostCollectionUpdateEventListeners(tempPostCollectionUpdateEventListeners
        .toArray(new PostCollectionUpdateEventListener[tempPostCollectionUpdateEventListeners.size()]));

    PostCollectionRemoveEventListener[] postCollectionRemoveEventListeners = eventListeners
        .getPostCollectionRemoveEventListeners();
    List<PostCollectionRemoveEventListener> tempPostCollectionRemoveEventListeners = Lists.newArrayList();
    for (PostCollectionRemoveEventListener postCollectionRemoveEventListener : postCollectionRemoveEventListeners) {
      if (!(postCollectionRemoveEventListener instanceof HibernateEventListener)) {
        tempPostCollectionRemoveEventListeners.add(postCollectionRemoveEventListener);
      }
    }
    eventListeners.setPostCollectionRemoveEventListeners(tempPostCollectionRemoveEventListeners
        .toArray(new PostCollectionRemoveEventListener[tempPostCollectionRemoveEventListeners.size()]));

  }
View Full Code Here


    propertyReferences = new ArrayList();
    secondPasses = new ArrayList();
    interceptor = EmptyInterceptor.INSTANCE;
    properties = Environment.getProperties();
    entityResolver = XMLHelper.DEFAULT_DTD_RESOLVER;
    eventListeners = new EventListeners();
    filterDefinitions = new HashMap();
//    extendsQueue = new ArrayList();
    extendsQueue = new HashMap();
    auxiliaryDatabaseObjects = new ArrayList();
    tableNameBinding = new HashMap();
View Full Code Here

        sessionFactoryObserver
      );
  }

  private EventListeners getInitializedEventListeners() {
    EventListeners result = (EventListeners) eventListeners.shallowCopy();
    result.initializeListeners( this );
    return result;
  }
View Full Code Here

    xmlHelper = new XMLHelper();
    interceptor = EmptyInterceptor.INSTANCE;
    properties = Environment.getProperties();
    entityResolver = XMLHelper.DEFAULT_DTD_RESOLVER;
    eventListeners = new EventListeners();

    sqlFunctions = new HashMap<String, SQLFunction>();

    entityTuplizerFactory = new EntityTuplizerFactory();
//    componentTuplizerFactory = new ComponentTuplizerFactory();
View Full Code Here

      log.debug( "Unable to execute {}, ignoring event listener registration.", SEARCH_STARTUP_METHOD );
    }
  }

  private EventListeners getInitializedEventListeners() {
    EventListeners result = (EventListeners) eventListeners.shallowCopy();
    result.initializeListeners( this );
    return result;
  }
View Full Code Here


  public void testListeners() throws Exception {
    EntityManagerFactory emf = Persistence.createEntityManagerFactory( "manager1", new HashMap() );
    EntityManager em = emf.createEntityManager();
    EventListeners eventListeners = ( (SessionImplementor) em.getDelegate() ).getListeners();
    assertEquals(
        "Explicit pre-insert event through hibernate.ejb.event.pre-insert does not work",
        eventListeners.getPreInsertEventListeners().length,
        eventListeners.getPreUpdateEventListeners().length + 1 );

    em.close();
    emf.close();
  }
View Full Code Here

    namingStrategy = DefaultNamingStrategy.INSTANCE;
    xmlHelper = new XMLHelper();
    interceptor = EmptyInterceptor.INSTANCE;
    properties = Environment.getProperties();
    entityResolver = XMLHelper.DEFAULT_DTD_RESOLVER;
    eventListeners = new EventListeners();

    sqlFunctions = new HashMap();

    entityTuplizerFactory = new EntityTuplizerFactory();
//    componentTuplizerFactory = new ComponentTuplizerFactory();
View Full Code Here

        sessionFactoryObserver
      );
  }

  private EventListeners getInitializedEventListeners() {
    EventListeners result = (EventListeners) eventListeners.shallowCopy();
    result.initializeListeners( this );
    return result;
  }
View Full Code Here

                    "Hibernate interceptor already set in persistence.xml ("
                                + configured.getInterceptor() + ")");
            }
        }
        if (this.postLoadEventListeners != null) {
            EventListeners el = configured.getEventListeners();
            List<PostLoadEventListener> listeners = new LinkedList(Arrays.asList(el.getPostLoadEventListeners()));
            listeners.addAll(this.postLoadEventListeners);
            el.setPostLoadEventListeners(listeners.toArray(new PostLoadEventListener[listeners.size()]));
        }
    }
View Full Code Here

        for (Map.Entry<String, Object> entry : this.eventListeners.entrySet()) {
          String listenerType = entry.getKey();
          Object listenerObject = entry.getValue();
          if (listenerObject instanceof Collection) {
            Collection<Object> listeners = (Collection<Object>) listenerObject;
            EventListeners listenerRegistry = config.getEventListeners();
            Object[] listenerArray =
                (Object[]) Array.newInstance(listenerRegistry.getListenerClassFor(listenerType), listeners.size());
            listenerArray = listeners.toArray(listenerArray);
            config.setListeners(listenerType, listenerArray);
          }
          else {
            config.setListener(listenerType, listenerObject);
View Full Code Here

TOP

Related Classes of org.hibernate.event.EventListeners

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.