当前位置: 首页>>代码示例>>Java>>正文


Java JdbcOperations类代码示例

本文整理汇总了Java中org.springframework.jdbc.core.JdbcOperations的典型用法代码示例。如果您正苦于以下问题:Java JdbcOperations类的具体用法?Java JdbcOperations怎么用?Java JdbcOperations使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JdbcOperations类属于org.springframework.jdbc.core包,在下文中一共展示了JdbcOperations类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTargetRepository

import org.springframework.jdbc.core.JdbcOperations; //导入依赖的package包/类
@Override
protected Object getTargetRepository(RepositoryInformation metadata) {
    entityClass = metadata.getDomainType();
    @SuppressWarnings("rawtypes")
    ReflectionJdbcRepository repository = getTargetRepositoryViaReflection(metadata, entityClass);
    repository.setDataSource(datasource);
    repository.afterPropertiesSet();
    this.repository = repository;

    generator = SqlGeneratorFactory.getInstance().getGenerator(datasource);
    template = new NamedParameterJdbcTemplate((JdbcOperations) extractRepositoryField(repository, FIELD_JDBC_OPS));
    rowMapper = extractRepositoryField(repository, FIELD_ROWMAPPER);
    tableDescription = extractRepositoryField(repository, FIELD_TABLE_DESCRIPTION);

    return repository;
}
 
开发者ID:rubasace,项目名称:spring-data-jdbc,代码行数:17,代码来源:JdbcRepositoryFactory.java

示例2: should_return_external_executor_runner

import org.springframework.jdbc.core.JdbcOperations; //导入依赖的package包/类
@Test
public void should_return_external_executor_runner() throws Exception {
    QueueConsumer queueConsumer = mock(QueueConsumer.class);
    QueueSettings settings = QueueSettings.builder().withBetweenTaskTimeout(Duration.ZERO).withNoTaskTimeout(Duration.ZERO)
            .withProcessingMode(ProcessingMode.USE_EXTERNAL_EXECUTOR).build();
    QueueLocation location = QueueLocation.builder().withTableName("testTable")
            .withQueueId(new QueueId("testQueue")).build();
    when(queueConsumer.getQueueConfig()).thenReturn(new QueueConfig(location, settings));

    QueueRunner queueRunner = QueueRunner.Factory.createQueueRunner(queueConsumer,
            new QueueDao(new QueueShardId("s1"), mock(JdbcOperations.class), mock(TransactionOperations.class)),
            mock(TaskLifecycleListener.class),
            mock(Executor.class));

    assertThat(queueRunner, CoreMatchers.instanceOf(QueueRunnerInExternalExecutor.class));

}
 
开发者ID:yandex-money,项目名称:db-queue,代码行数:18,代码来源:QueueRunnerFactoryTest.java

示例3: should_return_separate_transactions_runner

import org.springframework.jdbc.core.JdbcOperations; //导入依赖的package包/类
@Test
public void should_return_separate_transactions_runner() throws Exception {
    QueueConsumer queueConsumer = mock(QueueConsumer.class);
    QueueSettings settings = QueueSettings.builder().withBetweenTaskTimeout(Duration.ZERO).withNoTaskTimeout(Duration.ZERO)
            .withProcessingMode(ProcessingMode.SEPARATE_TRANSACTIONS).build();
    QueueLocation location = QueueLocation.builder().withTableName("testTable")
            .withQueueId(new QueueId("testQueue")).build();
    when(queueConsumer.getQueueConfig()).thenReturn(new QueueConfig(location, settings));

    QueueRunner queueRunner = QueueRunner.Factory.createQueueRunner(queueConsumer,
            new QueueDao(new QueueShardId("s1"), mock(JdbcOperations.class), mock(TransactionOperations.class)),
            mock(TaskLifecycleListener.class),
            null);

    assertThat(queueRunner, CoreMatchers.instanceOf(QueueRunnerInSeparateTransactions.class));
}
 
开发者ID:yandex-money,项目名称:db-queue,代码行数:17,代码来源:QueueRunnerFactoryTest.java

示例4: should_return_wrap_in_transaction_runner

import org.springframework.jdbc.core.JdbcOperations; //导入依赖的package包/类
@Test
public void should_return_wrap_in_transaction_runner() throws Exception {
    QueueConsumer queueConsumer = mock(QueueConsumer.class);
    QueueSettings settings = QueueSettings.builder().withBetweenTaskTimeout(Duration.ZERO).withNoTaskTimeout(Duration.ZERO)
            .withProcessingMode(ProcessingMode.WRAP_IN_TRANSACTION).build();
    QueueLocation location = QueueLocation.builder().withTableName("testTable")
            .withQueueId(new QueueId("testQueue")).build();
    when(queueConsumer.getQueueConfig()).thenReturn(new QueueConfig(location, settings));

    QueueRunner queueRunner = QueueRunner.Factory.createQueueRunner(queueConsumer,
            new QueueDao(new QueueShardId("s1"), mock(JdbcOperations.class), mock(TransactionOperations.class)),
            mock(TaskLifecycleListener.class),
            null);

    assertThat(queueRunner, CoreMatchers.instanceOf(QueueRunnerInTransaction.class));
}
 
开发者ID:yandex-money,项目名称:db-queue,代码行数:17,代码来源:QueueRunnerFactoryTest.java

示例5: executeBatchUpdateWithNamedParameters

import org.springframework.jdbc.core.JdbcOperations; //导入依赖的package包/类
public static int[] executeBatchUpdateWithNamedParameters(final ParsedSql parsedSql,
		final SqlParameterSource[] batchArgs, JdbcOperations jdbcOperations) {
	if (batchArgs.length <= 0) {
		return new int[] {0};
	}
	String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, batchArgs[0]);
	return jdbcOperations.batchUpdate(
			sqlToUse,
			new BatchPreparedStatementSetter() {

				@Override
				public void setValues(PreparedStatement ps, int i) throws SQLException {
					Object[] values = NamedParameterUtils.buildValueArray(parsedSql, batchArgs[i], null);
					int[] columnTypes = NamedParameterUtils.buildSqlTypeArray(parsedSql, batchArgs[i]);
					setStatementParameters(values, ps, columnTypes);
				}

				@Override
				public int getBatchSize() {
					return batchArgs.length;
				}
			});
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:NamedParameterBatchUpdateUtils.java

示例6: getMapList

import org.springframework.jdbc.core.JdbcOperations; //导入依赖的package包/类
/**
 * return a map of the objects, divided into their transactions indexes.
 *
 * @param jdbcOperations
 *            the jdbc operations to use.
 * @param sqlKey
 *            the sql key to use.
 * @param sqlArgsBaList
 *            the byte arrays to use for SQL arguments.
 * @param mapToObject
 *            the mapToObject to use.
 * @param <T>
 *            the object type to use.
 * @return a map of the objects, divided into their transactions indexes.
 */
private <T> Map<Integer, List<T>> getMapList(final JdbcOperations jdbcOperations, final String sqlKey,
		final AbstractMapToObject<T> mapToObject, final byte[]... sqlArgsBaList) {
	final String sql = getSql(sqlKey);

	final List<Map<String, Object>> mapList = jdbcOperations.queryForList(sql, (Object[]) sqlArgsBaList);

	final Map<Integer, List<T>> tMapList = new TreeMap<>();
	for (final Map<String, Object> map : mapList) {
		final byte[] transactionIndexBa = (byte[]) map.get(TRANSACTION_INDEX);
		final T t = mapToObject.toObject(map);
		final int transactionIndex = getTransactionIndex(transactionIndexBa);
		if (!tMapList.containsKey(transactionIndex)) {
			tMapList.put(transactionIndex, new ArrayList<>());
		}
		tMapList.get(transactionIndex).add(t);
	}

	return tMapList;
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:35,代码来源:BlockDbH2Impl.java

示例7: getTransactionInputsWithIndex

import org.springframework.jdbc.core.JdbcOperations; //导入依赖的package包/类
/**
 * gets the inputs for each transaction in the block, and adds them to the
 * transaction.
 *
 * @param block
 *            the block to use
 * @param jdbcOperations
 *            the jdbc operations to use.
 * @param blockIndexBa
 *            the block index to use.
 */
private void getTransactionInputsWithIndex(final Block block, final JdbcOperations jdbcOperations,
		final byte[] blockIndexBa) {
	final Map<Integer, List<CoinReference>> inputsMap = getMapList(jdbcOperations,
			"getTransactionInputsWithBlockIndex", new CoinReferenceMapToObject(), blockIndexBa);
	for (final int txIx : inputsMap.keySet()) {
		final List<CoinReference> inputs = inputsMap.get(txIx);

		if (txIx >= block.getTransactionList().size()) {
			throw new RuntimeException(
					"txIx \"" + txIx + "\" exceeds txList.size \"" + block.getTransactionList().size()
							+ "\" for block index \"" + block.getIndexAsLong() + "\" hash \"" + block.hash + "\"");
		} else {
			block.getTransactionList().get(txIx).inputs.addAll(inputs);
		}
	}
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:28,代码来源:BlockDbH2Impl.java

示例8: DefaultCalendarService

import org.springframework.jdbc.core.JdbcOperations; //导入依赖的package包/类
@Autowired
public DefaultCalendarService(final EventDao eventDao,
                              final CalendarUserDao userDao,
                              final JdbcOperations jdbcOperations,
                              final PasswordEncoder passwordEncoder) {
    if (eventDao == null) {
        throw new IllegalArgumentException("eventDao cannot be null");
    }
    if (userDao == null) {
        throw new IllegalArgumentException("userDao cannot be null");
    }
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    if (passwordEncoder == null) {
        throw new IllegalArgumentException("passwordEncoder cannot be null");
    }
    this.eventDao = eventDao;
    this.userDao = userDao;
    this.jdbcOperations = jdbcOperations;
    this.passwordEncoder = passwordEncoder;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:23,代码来源:DefaultCalendarService.java

示例9: DefaultCalendarService

import org.springframework.jdbc.core.JdbcOperations; //导入依赖的package包/类
@Autowired
public DefaultCalendarService(final EventDao eventDao,
                              final CalendarUserDao userDao,
                              final JdbcOperations jdbcOperations) {
    if (eventDao == null) {
        throw new IllegalArgumentException("eventDao cannot be null");
    }
    if (userDao == null) {
        throw new IllegalArgumentException("userDao cannot be null");
    }
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.eventDao = eventDao;
    this.userDao = userDao;
    this.jdbcOperations = jdbcOperations;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:18,代码来源:DefaultCalendarService.java

示例10: addVersions

import org.springframework.jdbc.core.JdbcOperations; //导入依赖的package包/类
/**
 * Add the given versions to the given project
 * 
 * @param dataSource
 *            The data source of JIRA database.
 * @param jira
 *            the JIRA project identifier.
 * @param versions
 *            the version names to add
 * @return the {@link Map} where value is the created version identifier.
 */
public Map<String, Integer> addVersions(final DataSource dataSource, final int jira,
		final Collection<String> versions) {
	final Map<String, Integer> result = new HashMap<>();
	final JdbcOperations jdbcTemplate = new JdbcTemplate(dataSource);
	int nextId = prepareForNextId(dataSource, VERSION_NODE, versions.size());
	int nextSequence = getNextVersionSequence(jira, jdbcTemplate);
	for (final String version : versions) {
		jdbcTemplate.update("INSERT INTO projectversion (ID,PROJECT,vname,SEQUENCE) values(?,?,?,?)", nextId, jira,
				version, nextSequence);
		result.put(version, nextId);
		nextId++;
		nextSequence++;
	}
	return result;
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:27,代码来源:JiraUpdateDao.java

示例11: getCurrentSequence

import org.springframework.jdbc.core.JdbcOperations; //导入依赖的package包/类
/**
 * Return current sequence.
 */
protected int getCurrentSequence(final String sequenceName, final JdbcOperations jdbcTemplate) {
	final Long currentSequence;
	final List<Long> sequence = jdbcTemplate
			.queryForList("SELECT SEQ_ID FROM SEQUENCE_VALUE_ITEM WHERE SEQ_NAME = ?", Long.class, sequenceName);
	if (sequence.isEmpty()) {
		// New sequence, start from an arbitrary sequence to be sure JIRA
		// does not fill it
		currentSequence = 10000L;
		jdbcTemplate.update("INSERT INTO SEQUENCE_VALUE_ITEM (SEQ_NAME,SEQ_ID) values(?,?)", sequenceName,
				currentSequence);
	} else {
		currentSequence = sequence.get(0);
	}
	return currentSequence.intValue();
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:19,代码来源:JiraUpdateDao.java

示例12: testPrepareForNextIdConcurrent

import org.springframework.jdbc.core.JdbcOperations; //导入依赖的package包/类
@Test
public void testPrepareForNextIdConcurrent() throws Exception {
	final JiraUpdateDao dao = new JiraUpdateDao() {

		private boolean mock = true;

		@Override
		protected int getCurrentSequence(final String sequenceName, final JdbcOperations jdbcTemplate) {
			if (mock) {
				mock = false;
				return -10000;
			}
			return super.getCurrentSequence(sequenceName, jdbcTemplate);
		}

	};
	Assert.assertEquals(10100, dao.prepareForNextId(datasource, "ChangeGroup", 2000));
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:19,代码来源:JiraUpdateDaoTest.java

示例13: addIssues

import org.springframework.jdbc.core.JdbcOperations; //导入依赖的package包/类
/**
 * Indicate the installation and activation of "script runner" plug-in.
 * 
 * @param dataSource
 *            The data source of JIRA database.
 * @param jira
 *            the JIRA project identifier.
 * @param issues
 *            The issues to add. The ID property of each inserted issue is
 *            also updated in these objects.
 * @param workflowStepMapping
 *            the {@link Map} linking type identifier to a {@link Map}
 *            linking status name to steps.
 */
public void addIssues(final DataSource dataSource, final int jira, final List<JiraIssueRow> issues,
		final Map<Integer, Workflow> workflowStepMapping) {
	final JdbcOperations jdbcTemplate = new JdbcTemplate(dataSource);
	int nextId = prepareForNextId(dataSource, ISSUE_NODE, issues.size());
	reserveProjectCounter(dataSource, jira, issues);
	int nextCurrentStepId = prepareForNextId(dataSource, "OSCurrentStep", issues.size());
	int nextWfEntryId = prepareForNextId(dataSource, "OSWorkflowEntry", issues.size());
	int counter = 0;
	for (final JiraIssueRow issueRow : issues) {
		issueRow.setId(nextId);
		log.info("Inserting issue {}-{}({}) {}/{}", issueRow.getPkey(), issueRow.getIssueNum(), issueRow.getId(),
				counter, issues.size());
		Workflow workflow = workflowStepMapping.get(issueRow.getType());
		if (workflow == null) {
			workflow = workflowStepMapping.get(0);
		}

		addIssue(jira, jdbcTemplate, nextId, nextCurrentStepId, nextWfEntryId, issueRow, workflow);
		nextId++;
		nextWfEntryId++;
		nextCurrentStepId++;
		counter++;
	}
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:39,代码来源:JiraUpdateDao.java

示例14: addIssue

import org.springframework.jdbc.core.JdbcOperations; //导入依赖的package包/类
/**
 * Add an issue, workflow entry, corresponding step of current status and link author to this issue (user activity
 * dashboard)
 */
private void addIssue(final int jira, final JdbcOperations jdbcTemplate, final int nextId, final int nextCurrentStepId, final int nextWfEntryId,
		final JiraIssueRow issueRow, final Workflow workflow) {
	final INamableBean<Integer> workflowStep = workflow.getStatusToSteps().get(issueRow.getStatusText());

	// Insert workflow activity
	jdbcTemplate.update("INSERT INTO OS_WFENTRY (ID,NAME,STATE) values(?,?,?)", nextWfEntryId, workflow.getName(), 1);
	jdbcTemplate.update("INSERT INTO OS_CURRENTSTEP (ID,ENTRY_ID,STEP_ID,ACTION_ID,START_DATE,STATUS) values(?,?,?,?,?,?)", nextCurrentStepId,
			nextWfEntryId, workflowStep.getId(), 0, issueRow.getCreated(), workflowStep.getName());

	// Insert issue
	jdbcTemplate.update(
			"INSERT INTO jiraissue"
					+ " (ID,issuenum,WATCHES,VOTES,PROJECT,REPORTER,ASSIGNEE,CREATOR,issuetype,SUMMARY,DESCRIPTION,PRIORITY,RESOLUTION,RESOLUTIONDATE,"
					+ "issuestatus,CREATED,UPDATED,WORKFLOW_ID,DUEDATE) values(?,?,1,0,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
			nextId, issueRow.getIssueNum(), jira, issueRow.getReporter(), issueRow.getAssignee(), issueRow.getAuthor(), issueRow.getType(),
			issueRow.getSummary(), issueRow.getDescription(), issueRow.getPriority(), issueRow.getResolution(), issueRow.getResolutionDate(),
			issueRow.getStatus(), issueRow.getCreated(), issueRow.getUpdated(), nextWfEntryId, issueRow.getDueDate());

	// Add user relation
	jdbcTemplate.update("INSERT INTO userassociation (SOURCE_NAME,SINK_NODE_ID,SINK_NODE_ENTITY,ASSOCIATION_TYPE,CREATED) values(?,?,?,?,?)",
			issueRow.getAuthor(), nextId, "Issue", "WatchIssue", issueRow.getUpdated());
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:27,代码来源:JiraUpdateDao.java

示例15: OAuth2Configuration

import org.springframework.jdbc.core.JdbcOperations; //导入依赖的package包/类
public OAuth2Configuration(ResourceLoader resourceLoader, OpenIdProviderProperties properties,
		ObjectProvider<JdbcOperations> jdbcOperations, ObjectProvider<AuthenticationManager> authenticationManager,
		ObjectProvider<HazelcastInstance> hazelcastInstance) {
	this.resourceLoader = resourceLoader;
	this.properties = properties;
	this.jdbcOperations = jdbcOperations.getObject();
	this.authenticationManager = authenticationManager.getObject();
	this.hazelcastInstance = hazelcastInstance.getObject();
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:10,代码来源:OAuth2Configuration.java


注:本文中的org.springframework.jdbc.core.JdbcOperations类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。