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

The following examples show how to use org.javers.repository.sql.ConnectionProvider. 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: JaversSqlAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean(name = "JaversSqlRepositoryFromStarter")
@ConditionalOnMissingBean
public JaversSqlRepository javersSqlRepository(ConnectionProvider connectionProvider) {
    return SqlRepositoryBuilder
            .sqlRepository()
            .withSchema(javersSqlProperties.getSqlSchema())
            .withConnectionProvider(connectionProvider)
            .withDialect(javersSqlDialectName())
            .withSchemaManagementEnabled(javersSqlProperties.isSqlSchemaManagementEnabled())
            .withGlobalIdCacheDisabled(javersSqlProperties.isSqlGlobalIdCacheDisabled())
            .build();
}
 
Example 3
Source Project: javers   Source File: JaversSchemaManager.java    License: Apache License 2.0 5 votes vote down vote up
public JaversSchemaManager(Dialect dialect, FixedSchemaFactory schemaFactory, PolyJDBC polyJDBC, ConnectionProvider connectionProvider, TableNameProvider tableNameProvider) {
    super(tableNameProvider);
    this.dialect = dialect;
    this.schemaFactory = schemaFactory;
    this.polyJDBC = polyJDBC;
    this.connectionProvider = connectionProvider;
}
 
Example 4
Source Project: dolphin-platform   Source File: AuditContext.java    License: Apache License 2.0 4 votes vote down vote up
public AuditContext(final ConnectionProvider connectionProvider, final String dialect, final String schema) {
    this(connectionProvider, convertToDialect(dialect), schema);
}
 
Example 5
Source Project: javers   Source File: JaversSqlAutoConfiguration.java    License: Apache License 2.0 4 votes vote down vote up
@Bean(name = "JpaHibernateConnectionProvider")
@ConditionalOnMissingBean
public ConnectionProvider jpaConnectionProvider() {
    return new JpaHibernateConnectionProvider();
}
 
Example 6
Source Project: javers   Source File: JaversSpringJpaApplicationConfig.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Integrates {@link JaversSqlRepository} with Spring {@link JpaTransactionManager}
 */
@Bean
public ConnectionProvider jpaConnectionProvider() {
    return new JpaHibernateConnectionProvider();
}
 
Example 7
Source Project: javers   Source File: HibernateConfig.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Integrates {@link JaversSqlRepository} with Spring {@link JpaTransactionManager}
 */
@Bean
public ConnectionProvider jpaConnectionProvider() {
    return new JpaHibernateConnectionProvider();
}
 
Example 8
Source Project: javers   Source File: Session.java    License: Apache License 2.0 4 votes vote down vote up
Session(Dialect dialect, KeyGenerator keyGenerator, ConnectionProvider connectionProvider, String sessionName) {
    this.dialect = dialect;
    this.connectionProvider = connectionProvider;
    this.sessionName = sessionName;
    this.keyGenerator = keyGenerator;
}
 
Example 9
Source Project: javers   Source File: PreparedStatementExecutor.java    License: Apache License 2.0 4 votes vote down vote up
PreparedStatementExecutor(ConnectionProvider connectionProvider, Query query) {
    this.rawSql = query.rawSQl();
    this.queryName = query.name();
    this.statement = wrapExceptionAndCall(() -> connectionProvider.getConnection().prepareStatement(this.rawSql));
}
 
Example 10
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();
}