Java源码示例:org.springframework.data.jdbc.core.JdbcAggregateTemplate

示例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;
}
 
示例2
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);
	}
}
 
示例3
public WithInsertImpl(JdbcAggregateTemplate template) {
	this.template = template;
}