Java Code Examples for org.springframework.data.jdbc.core.JdbcAggregateTemplate

The following examples show how to use org.springframework.data.jdbc.core.JdbcAggregateTemplate. 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
@Override
protected Object getTargetRepository(RepositoryInformation repositoryInformation) {

    JdbcAggregateTemplate template = new JdbcAggregateTemplate(publisher, context, converter, accessStrategy);

    Class<?> type = repositoryInformation.getDomainType();
    RelationalPath<?> relationalPathBase = getRelationalPathBase(repositoryInformation);
    ConstructorExpression<?> constructor = getConstructorExpression(type, relationalPathBase);
    SimpleQuerydslJdbcRepository<?, ?> repository = new SimpleQuerydslJdbcRepository(template,
                                                                                        context.getRequiredPersistentEntity(
                                                                                                type),
                                                                                        sqlQueryFactory,
                                                                                        constructor,
                                                                                        relationalPathBase);

    if (entityCallbacks != null) {
        template.setEntityCallbacks(entityCallbacks);
    }

    return repository;
}
 
Example 2
Source Project: spring-data-dev-tools   Source File: JdbcFixture.java    License: Apache License 2.0 6 votes vote down vote up
private static void disableEntityCallbacks(ApplicationContext context) {
	
	JdbcBookRepository repository = context.getBean(JdbcBookRepository.class);

	Field field = ReflectionUtils.findField(SimpleJdbcRepository.class, "entityOperations");
	ReflectionUtils.makeAccessible(field);
	
	try {
		JdbcAggregateTemplate aggregateTemplate = (JdbcAggregateTemplate) ReflectionUtils.getField(field,
				((Advised) repository).getTargetSource().getTarget());

		field = ReflectionUtils.findField(JdbcAggregateTemplate.class, "publisher");
		ReflectionUtils.makeAccessible(field);
		ReflectionUtils.setField(field, aggregateTemplate, NoOpApplicationEventPublisher.INSTANCE);
		
		aggregateTemplate.setEntityCallbacks(NoOpEntityCallbacks.INSTANCE);
		
	} catch (Exception o_O) {
		throw new RuntimeException(o_O);
	}
}
 
Example 3
Source Project: spring-data-examples   Source File: WithInsertImpl.java    License: Apache License 2.0 4 votes vote down vote up
public WithInsertImpl(JdbcAggregateTemplate template) {
	this.template = template;
}