Java Code Examples for org.javers.repository.sql.DialectName

The following examples show how to use org.javers.repository.sql.DialectName. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: cia   Source File: AuditableAspectConfiguration.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Gets the javers.
 *
 * @param txManager the tx manager
 * @return the javers
 */
@Bean
public Javers getJavers(final PlatformTransactionManager txManager) {
	final JaversSqlRepository sqlRepository = SqlRepositoryBuilder.sqlRepository()
			.withConnectionProvider(new ConnectionProvider() {

				@Override
				public Connection getConnection() {
					final SessionImpl session = (SessionImpl) entityManager.unwrap(Session.class);

					return session.connection();
				}
			}).withDialect(DialectName.POSTGRES).build();

	return TransactionalJaversBuilder.javers().withTxManager(txManager)
			.withObjectAccessHook(new HibernateUnproxyObjectAccessHook()).registerJaversRepository(sqlRepository)
			.withMappingStyle(MappingStyle.BEAN).build();
}
 
Example 2
Source Project: javers   Source File: DialectMapper.java    License: Apache License 2.0 6 votes vote down vote up
public DialectName map(Dialect hibernateDialect) {

        if (hibernateDialect instanceof SQLServerDialect) {
            return DialectName.MSSQL;
        }
        if (hibernateDialect instanceof H2Dialect){
            return DialectName.H2;
        }
        if (hibernateDialect instanceof Oracle8iDialect){
            return DialectName.ORACLE;
        }
        if (hibernateDialect instanceof PostgreSQL81Dialect){
            return DialectName.POSTGRES;
        }
        if (hibernateDialect instanceof MySQLDialect){
            return DialectName.MYSQL;
        }
        throw new JaversException(JaversExceptionCode.UNSUPPORTED_SQL_DIALECT, hibernateDialect.getClass().getSimpleName());
    }
 
Example 3
Source Project: javers   Source File: JaversSpringJpaApplicationConfig.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates JaVers instance with {@link JaversSqlRepository}
 */
@Bean
public Javers javers(PlatformTransactionManager txManager) {
    JaversSqlRepository sqlRepository = SqlRepositoryBuilder
            .sqlRepository()
            .withConnectionProvider(jpaConnectionProvider())
            .withDialect(DialectName.H2)
            .build();

    return TransactionalJaversBuilder
            .javers()
            .withTxManager(txManager)
            .withObjectAccessHook(new HibernateUnproxyObjectAccessHook())
            .registerJaversRepository(sqlRepository)
            .build();
}
 
Example 4
Source Project: javers   Source File: Dialects.java    License: Apache License 2.0 6 votes vote down vote up
static Dialect fromName(DialectName dialectName) {
    if (DialectName.H2 == dialectName) {
        return new H2(dialectName);
    }
    if (DialectName.MYSQL == dialectName) {
        return new MysqlDialect(dialectName);
    }
    if (DialectName.POSTGRES == dialectName) {
        return new PostgresDialect(dialectName);
    }
    if (DialectName.ORACLE == dialectName) {
        return new OracleDialect(dialectName);
    }
    if (DialectName.MSSQL == dialectName) {
        return new MsSqlDialect(dialectName);
    }
    throw new JaversException(JaversExceptionCode.UNSUPPORTED_SQL_DIALECT, dialectName);
}
 
Example 5
Source Project: dolphin-platform   Source File: AuditContext.java    License: Apache License 2.0 5 votes vote down vote up
private static DialectName convertToDialect(final String dialectName) {
    if(dialectName.equals(DB_H2)) {
        return DialectName.H2;
    }
    if(dialectName.equals(DB_POSTGRES)) {
        return DialectName.POSTGRES;
    }
    if(dialectName.equals(DB_MYSQL)) {
        return DialectName.MYSQL;
    }
    throw new DolphinRuntimeException("Dialect not supported");
}
 
Example 6
Source Project: javers   Source File: JaversSqlAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public DialectName javersSqlDialectName() {
    SessionFactoryImplementor sessionFactory =
            (SessionFactoryImplementor) entityManagerFactory.unwrap(SessionFactory.class);

    Dialect hibernateDialect = sessionFactory.getDialect();
    logger.info("detected Hibernate dialect: " + hibernateDialect.getClass().getSimpleName());

    return dialectMapper.map(hibernateDialect);
}
 
Example 7
Source Project: javers   Source File: Dialects.java    License: Apache License 2.0 4 votes vote down vote up
H2(DialectName dialectName) {
    super(dialectName);
}
 
Example 8
Source Project: javers   Source File: Dialects.java    License: Apache License 2.0 4 votes vote down vote up
MysqlDialect(DialectName dialectName) {
    super(dialectName);
}
 
Example 9
Source Project: javers   Source File: Dialects.java    License: Apache License 2.0 4 votes vote down vote up
MsSqlDialect(DialectName dialectName) {
    super(dialectName);
}
 
Example 10
Source Project: javers   Source File: Dialects.java    License: Apache License 2.0 4 votes vote down vote up
PostgresDialect(DialectName dialectName) {
    super(dialectName);
}
 
Example 11
Source Project: javers   Source File: Dialects.java    License: Apache License 2.0 4 votes vote down vote up
OracleDialect(DialectName dialectName) {
    super(dialectName);
}
 
Example 12
Source Project: javers   Source File: SessionFactory.java    License: Apache License 2.0 4 votes vote down vote up
public SessionFactory(DialectName dialectName, ConnectionProvider connectionProvider) {
    this.dialect = Dialects.fromName(dialectName);
    this.connectionProvider = connectionProvider;
    this.keyGenerator = dialect.getKeyGeneratorDefinition().createKeyGenerator();
}
 
Example 13
Source Project: javers   Source File: Dialect.java    License: Apache License 2.0 4 votes vote down vote up
Dialect(DialectName dialectName) {
    Validate.argumentIsNotNull(dialectName);
    this.dialectName = dialectName;
}
 
Example 14
Source Project: javers   Source File: Dialect.java    License: Apache License 2.0 4 votes vote down vote up
DialectName getName() {
    return dialectName;
}