}
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()]));
}