Example usage for org.hibernate.engine.config.spi StandardConverters BOOLEAN

List of usage examples for org.hibernate.engine.config.spi StandardConverters BOOLEAN

Introduction

In this page you can find the example usage for org.hibernate.engine.config.spi StandardConverters BOOLEAN.

Prototype

Converter BOOLEAN

To view the source code for org.hibernate.engine.config.spi StandardConverters BOOLEAN.

Click Source Link

Usage

From source file:com.googlecode.hibernate.audit.listener.AuditListener.java

License:Open Source License

public void initialize(SessionFactoryImplementor sessionFactory, Metadata metadata,
        SessionFactoryServiceRegistry serviceRegistry) {
    try {//from  w  w w  .j ava 2s .c  om
        recordEmptyCollectionsOnInsert = serviceRegistry.getService(ConfigurationService.class).getSetting(
                HibernateAudit.AUDIT_RECORD_EMPTY_COLLECTIONS_ON_INSERT_PROPERTY, StandardConverters.BOOLEAN,
                true);

        auditConfiguration = ConfigurationHolder.getAuditConfiguration(sessionFactory);

        if (auditConfiguration == null) {
            Version.touch();
            auditConfiguration = new AuditConfiguration(sessionFactory, metadata);

            processDynamicUpdate(metadata, serviceRegistry);

            ConfigurationHolder.putAuditConfiguration(sessionFactory, auditConfiguration);

            processAuditConfigurationObserver(serviceRegistry);
        }
    } catch (RuntimeException e) {
        if (log.isErrorEnabled()) {
            log.error(
                    "RuntimeExcpetion occured during AuditListener initialization, will re-throw the exception",
                    e);
        }
        throw e;
    }
}

From source file:com.googlecode.hibernate.audit.listener.AuditListener.java

License:Open Source License

private void processDynamicUpdate(Metadata metadata, SessionFactoryServiceRegistry serviceRegistry) {
    if (serviceRegistry.getService(ConfigurationService.class).getSetting(
            HibernateAudit.AUDIT_SET_DYNAMIC_UPDATE_FOR_AUDITED_MODEL_PROPERTY, StandardConverters.BOOLEAN,
            false)) {//  w  ww. j av  a 2s  .c  o  m
        for (PersistentClass persistentClass : metadata.getEntityBindings()) {
            persistentClass.setDynamicUpdate(true);
            if (log.isInfoEnabled()) {
                log.info("Set dynamic-update to true for entity: " + persistentClass.getEntityName());
            }
        }
    }
}

From source file:org.ligoj.bootstrap.core.dao.SequenceIdentifierGeneratorStrategyProviderTest.java

License:MIT License

private ServiceRegistry newServiceRegistry() {
    var mock = Mockito.mock(ConfigurationService.class);
    Mockito.doReturn(true).when(mock).getSetting(
            AvailableSettings.PREFER_GENERATOR_NAME_AS_DEFAULT_SEQUENCE_NAME, StandardConverters.BOOLEAN, true);
    var jdbcEnvironment = newJdbcEnvironment();
    var serviceRegistry = Mockito.mock(ServiceRegistry.class);
    Mockito.when(serviceRegistry.getService(JdbcEnvironment.class)).thenReturn(jdbcEnvironment);
    Mockito.when(jdbcEnvironment.getDialect()).thenReturn(new MySQL55Dialect());
    Mockito.doReturn(mock).when(serviceRegistry).getService(ConfigurationService.class);
    return serviceRegistry;
}