org.javers.repository.sql.DialectName Java Examples

The following examples show how to use org.javers.repository.sql.DialectName. 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 File: AuditableAspectConfiguration.java    From cia with 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 File: DialectMapper.java    From javers with 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 File: JaversSpringJpaApplicationConfig.java    From javers with 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 File: Dialects.java    From javers with 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 File: AuditContext.java    From dolphin-platform with 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 File: JaversSqlAutoConfiguration.java    From javers with 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 File: Dialects.java    From javers with Apache License 2.0 4 votes vote down vote up
H2(DialectName dialectName) {
    super(dialectName);
}
 
Example #8
Source File: Dialects.java    From javers with Apache License 2.0 4 votes vote down vote up
MysqlDialect(DialectName dialectName) {
    super(dialectName);
}
 
Example #9
Source File: Dialects.java    From javers with Apache License 2.0 4 votes vote down vote up
MsSqlDialect(DialectName dialectName) {
    super(dialectName);
}
 
Example #10
Source File: Dialects.java    From javers with Apache License 2.0 4 votes vote down vote up
PostgresDialect(DialectName dialectName) {
    super(dialectName);
}
 
Example #11
Source File: Dialects.java    From javers with Apache License 2.0 4 votes vote down vote up
OracleDialect(DialectName dialectName) {
    super(dialectName);
}
 
Example #12
Source File: SessionFactory.java    From javers with 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 File: Dialect.java    From javers with Apache License 2.0 4 votes vote down vote up
Dialect(DialectName dialectName) {
    Validate.argumentIsNotNull(dialectName);
    this.dialectName = dialectName;
}
 
Example #14
Source File: Dialect.java    From javers with Apache License 2.0 4 votes vote down vote up
DialectName getName() {
    return dialectName;
}