Skip to content

DATAJDBC-437 - In strict mode we only claim repositories for domain types with @Table annotation. #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

schauder
Copy link
Contributor

Before this change Spring Data JDBC didn't specify any identifying annotation and therefore would claim all or no repository depending on the the version of Spring Data Commons.

Also added the RepositoryFactorySupport to spring.factory in order to support detection of multiple RepositoryFactorySupport implementations on the classpath.

See also: https://jira.spring.io/browse/DATACMNS-1596.

Original issue: https://jira.spring.io/browse/DATAJDBC-437.

…ypes with @table annotation.

Before this change Spring Data JDBC didn't specify any identifying annotation and therefore would claim all or no repository depending on the the version of Spring Data Commons.

Also added the RepositoryFactorySupport to spring.factory in order to support detection of multiple RepositoryFactorySupport implementations on the classpath.

See also: https://jira.spring.io/browse/DATACMNS-1596.
@schauder schauder requested a review from mp911de October 24, 2019 13:05
Copy link
Member

@mp911de mp911de left a comment

Choose a reason for hiding this comment

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

I left a few comments mostly to reduce the need for touching unrelated tests.

@@ -56,7 +58,8 @@

@Configuration
@Import(TestConfiguration.class)
@EnableJdbcRepositories(considerNestedRepositories = true)
@EnableJdbcRepositories(includeFilters = @Filter(type = FilterType.REGEX,
Copy link
Member

Choose a reason for hiding this comment

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

We should improve handling for non-existent entity types in JdbcRepositoryFactory.getTargetRepository(…) (e.g. calling getRequiredPersistentEntity(…) instead of getPersistentEntity(…)).

java.lang.IllegalArgumentException: entity is marked non-null but is null
	at org.springframework.data.jdbc.repository.support.SimpleJdbcRepository.<init>(SimpleJdbcRepository.java:36)

is hard to debug.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

* Unit tests for {@link JdbcRepositoryConfigExtension}.
*
* @author Jens Schauder
* @since 1.2
Copy link
Member

Choose a reason for hiding this comment

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

Nit: No need for @since in test classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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


interface SampleRepository extends Repository<Sample, Long> {}

interface UnannotatedRepository extends Repository<Object, Long> {}
Copy link
Member

Choose a reason for hiding this comment

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

Ideally, we don't use Object here to avoid the need to touch other, unrelated tests. Let's use a different type here.

The repository for an unannotated entity now can be constructed, avoiding the need to exclude it in other tests.

Improved error message for failure to create a repository by using `getRequiredPersistentEntity`.

Removed superfluous `@since` annotation.
@schauder
Copy link
Contributor Author

I implemented the suggested improvements.

mp911de pushed a commit that referenced this pull request Oct 25, 2019
…ypes with @table annotation.

Before this change Spring Data JDBC didn't specify any identifying annotation and therefore would claim all or no repository depending on the the version of Spring Data Commons.

Also added the RepositoryFactorySupport to spring.factory in order to support detection of multiple RepositoryFactorySupport implementations on the classpath.

Related ticket: DATACMNS-1596.
Original pull request: #177.
mp911de added a commit that referenced this pull request Oct 25, 2019
Remove unused imports.

Original pull request: #177.
mp911de pushed a commit that referenced this pull request Oct 25, 2019
…ypes with @table annotation.

Before this change Spring Data JDBC didn't specify any identifying annotation and therefore would claim all or no repository depending on the the version of Spring Data Commons.

Also added the RepositoryFactorySupport to spring.factory in order to support detection of multiple RepositoryFactorySupport implementations on the classpath.

Related ticket: DATACMNS-1596.
Original pull request: #177.
mp911de added a commit that referenced this pull request Oct 25, 2019
Remove unused imports.

Original pull request: #177.
@mp911de
Copy link
Member

mp911de commented Oct 25, 2019

That's merged, polished, and backported now.

@mp911de mp911de closed this Oct 25, 2019
@mp911de mp911de deleted the issue/DATAJDBC-437 branch October 25, 2019 07:57
schauder added a commit that referenced this pull request Oct 29, 2019
…ypes with @table annotation.

Before this change Spring Data JDBC didn't specify any identifying annotation and therefore would claim all or no repository depending on the the version of Spring Data Commons.

Also added the RepositoryFactorySupport to spring.factory in order to support detection of multiple RepositoryFactorySupport implementations on the classpath.

Related ticket: DATACMNS-1596.
Original pull request: #177.
schauder pushed a commit that referenced this pull request Oct 29, 2019
Remove unused imports.

Original pull request: #177.
mp911de added a commit that referenced this pull request Feb 21, 2022
mp911de added a commit that referenced this pull request Feb 21, 2022
Add this. for field access.
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