Skip to content

Conversation

gregturn
Copy link
Contributor

No description provided.

@gregturn
Copy link
Contributor Author

@schauder I have a demo app using this branch => https://github.com/gregturn/spring-data-jdbc-demo

@gregturn
Copy link
Contributor Author

This code now works with Spring Data REST, however, it surely isn't the best solution for the issues at hand.

@gregturn gregturn requested a review from schauder November 21, 2017 17:26
@gregturn gregturn self-assigned this Nov 21, 2017
@gregturn
Copy link
Contributor Author

@schauder I've run this latest version against our Spring Data JDBC demo (listed above) and it works perfectly, with the following configuration:

@Configuration
@EnableJdbcRepositories
public class JdbcConfig {

	@Bean
	DefaultDataAccessStrategy defaultDataAccessStrategy(JdbcMappingContext context,
														NamedParameterJdbcOperations operations) {
		return new DefaultDataAccessStrategy(new SqlGeneratorSource(context), operations, context);
	}
}

*/
package org.springframework.data.jdbc.mybatis;

import static org.assertj.core.api.Assertions.*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks we have different code formatters. I have the eclipse formatter configured with the import order coming from spring-data-build/etc/ide/eclipse-formatting.xml.

I think my configuration matches what I see for example in https://github.com/spring-projects/spring-data-jpa/blob/master/src/test/java/org/springframework/data/jpa/repository/support/QuerydslIntegrationTests.java

Applies to all files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check my IDE settings.

* @author Jens Schauder
* @author Greg Turnquist
*/
@RunWith(MockitoJUnitRunner.Silent.class)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the Silent runner? The normal one seems to work just as fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ollie used it in the JPA variant. At point it seemed to make a difference if we don't need it then we don't need it.

}

private Condition<? super RepositoryFactorySupport> using(JdbcOperations expectedOperations) {
private class DummyJpaRepositoryFactoryBean<T extends CrudRepository<S, ID>, S, ID extends Serializable>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that should be DummyJdbcRep..., right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh. Yes

assertThat(loadedClass).isNotNull();
ReflectionUtils.getAllDeclaredMethods(loadedClass);
// Setup standard configuration
factoryBean = new DummyJpaRepositoryFactoryBean<>(DummyEntityRepository.class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I replace this with

factoryBean = new JdbcRepositoryFactoryBean<>(DummyEntityRepository.class);

the tests seem to work just as well.
I'm afraid I don't understand what you try to achieve.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used Jpa's variant of this unit test as a guide.

public void setsUpBasicInstanceCorrectly() {

private Condition<? super RepositoryFactorySupport> using(NamedParameterJdbcOperations expectedOperations) {
factoryBean.setBeanFactory(beanFactory);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line doesn't seem to have an effect on the outcome of the class.

Class<?> testClass() {
return EnableJdbcRepositoriesIntegrationTests.class;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra line

In the past, Spring Data JDBC performed autoconfiguration such as gleaning whether or not MyBatis is on the classpath, and also whether or not certain other beans exist. This commit removes such flexible settings and instead wires up a JdbcMappingContext seeking an optional NamingStrategy and optional ConversionCustomizer. The other required beans will alert the end user if they don't exist.

All relevant test cases are updated to inject the proper components.

All autoconfiguration is being moved outside Spring Data JDBC, to eventually join Spring Boot after being shook out as an independent module.
@gregturn
Copy link
Contributor Author

@schauder I processed all your comments. I also spotted that I wasn't using the Eclipse Code Formatter. Switched that on, using all the settings providing by spring-data-build, and reformatting imports for all touched files.

@schauder
Copy link
Contributor

Resolved via: b044a13

@schauder schauder closed this Nov 28, 2017
@gregturn gregturn deleted the issue/DATAJDBC-151 branch December 4, 2017 15:26
mp911de added a commit that referenced this pull request Feb 21, 2022
…QL Server.

We now provide dialect support for H2, PostgreSQL, and Microsoft SQL Server databases, configurable through AbstractR2dbcConfiguration. By default, we obtain the Dialect by inspecting ConnectionFactoryMetadata to identify the database and the most likely dialect to use.

BindableOperation encapsulates statements/queries that can accept parameters. Use BindableOperation for statements through DatabaseClient.
Extract SQL creation.

Split integration test into abstract base class that can be implemented with a database-specific test class.

Original pull request: #24.
mp911de pushed a commit that referenced this pull request Feb 21, 2022
Rename Database.latestDialect() to defaultDialect(). Rename Dialect.returnGeneratedKeys() to Dialect.generatedKeysClause(). Simplify IndexBindMarkers. Create BindableOperation.bind(Statement, SettableValue) to reduce code duplicates. Rename BindSpecWrapper to BindSpecAdapter.

Original pull request: #24.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants