Java 类org.hibernate.event.spi.AbstractEvent 实例源码

项目:rpb    文件:AuditLogListener.java   
private void audit(AbstractEvent hibernateEvent, AuditEvent auditEvent, Object object, String attribute) {
    String className = object.getClass().getSimpleName();
    if (skipClasses.contains(className)) {
        return;
    }

    AuditLog auditLog = new AuditLog();
    auditLog.setUsername(UserContext.getUsername());
    auditLog.setEvent(auditEvent.name());
    auditLog.setEventDate(new Date());
    auditLog.setStringAttribute1(className);
    auditLog.setStringAttribute2(((Identifiable<?>) object).getId().toString());
    auditLog.setStringAttribute3(attribute);
    audit(hibernateEvent, auditLog);
}
项目:rpb    文件:AuditLogListener.java   
private void audit(AbstractEvent hibernateEvent, final AuditLog auditLog) {
    hibernateEvent.getSession().getActionQueue().registerProcess(new AfterTransactionCompletionProcess() {
        @Override
        public void doAfterTransactionCompletion(boolean success, SessionImplementor session) {
            if (success) {
                auditLogService.log(auditLog);
            }
        }
    });
}
项目:rpb    文件:AuditLogListener.java   
private void audit(AbstractEvent hibernateEvent, AuditEvent auditEvent, Object object, String attribute) {
    String className = object.getClass().getSimpleName();
    if (skipClasses.contains(className)) {
        return;
    }

    AuditLog auditLog = new AuditLog();
    auditLog.setUsername(UserContext.getUsername());
    auditLog.setEvent(auditEvent.name());
    auditLog.setEventDate(new Date());
    auditLog.setStringAttribute1(className);
    auditLog.setStringAttribute2(((Identifiable<?>) object).getId().toString());
    auditLog.setStringAttribute3(attribute);
    audit(hibernateEvent, auditLog);
}
项目:rpb    文件:AuditLogListener.java   
private void audit(AbstractEvent hibernateEvent, final AuditLog auditLog) {
    hibernateEvent.getSession().getActionQueue().registerProcess(new AfterTransactionCompletionProcess() {
        @Override
        public void doAfterTransactionCompletion(boolean success, SessionImplementor session) {
            if (success) {
                auditLogService.log(auditLog);
            }
        }
    });
}
项目:Hibernate-Search-GenericJPA    文件:HibernateUpdateSource.java   
protected void processWork(
        Object entity,
        Serializable id,
        WorkType workType,
        AbstractEvent event,
        boolean identifierRollbackEnabled) {
    Work work = new Work( entity, id, workType, identifierRollbackEnabled );
    final EventSourceTransactionContext transactionContext = new EventSourceTransactionContext( event.getSession() );
    transactionContext.registerSynchronization(
            new Synchronization() {
                @Override
                public void beforeCompletion() {

                }

                @Override
                public void afterCompletion(int status) {
                    if ( Status.STATUS_COMMITTED == status ) {
                        HibernateUpdateSource.this.notify(
                                Collections.singletonList(
                                        new UpdateConsumer.UpdateEventInfo(
                                                INITIALIZER.getClass( entity ), id, workTypeToEventType( workType )
                                        )
                                )
                        );
                    }
                }
            }
    );
    extendedIntegrator.getWorker().performWork( work, transactionContext );
}
项目:lams    文件:AbstractReassociateEventListener.java   
/**
 * Associates a given entity (either transient or associated with another session) to
 * the given session.
 *
 * @param event The event triggering the re-association
 * @param object The entity to be associated
 * @param id The id of the entity.
 * @param persister The entity's persister instance.
 *
 * @return An EntityEntry representing the entity within this session.
 */
protected final EntityEntry reassociate(AbstractEvent event, Object object, Serializable id, EntityPersister persister) {

    if ( log.isTraceEnabled() ) {
        log.tracev(
                "Reassociating transient instance: {0}",
                MessageHelper.infoString( persister, id, event.getSession().getFactory() )
        );
    }

    final EventSource source = event.getSession();
    final EntityKey key = source.generateEntityKey( id, persister );

    source.getPersistenceContext().checkUniqueness( key, object );

    //get a snapshot
    Object[] values = persister.getPropertyValues( object );
    TypeHelper.deepCopy(
            values,
            persister.getPropertyTypes(),
            persister.getPropertyUpdateability(),
            values,
            source
    );
    Object version = Versioning.getVersion( values, persister );

    EntityEntry newEntry = source.getPersistenceContext().addEntity(
            object,
            ( persister.isMutable() ? Status.MANAGED : Status.READ_ONLY ),
            values,
            key,
            version,
            LockMode.NONE,
            true,
            persister,
            false,
            true //will be ignored, using the existing Entry instead
    );

    new OnLockVisitor( source, id, object ).process( object, persister );

    persister.afterReassociate( object, source );

    return newEntry;

}
项目:rpb    文件:AuditLogListener.java   
private void audit(AbstractEvent hibernateEvent, AuditEvent auditEvent, Object object) {
    audit(hibernateEvent, auditEvent, object, null);
}
项目:rpb    文件:AuditLogListener.java   
private void audit(AbstractEvent hibernateEvent, AuditEvent auditEvent, Object object) {
    audit(hibernateEvent, auditEvent, object, null);
}