Browse Source

DATAJDBC-506 - Fix some typos in code and documentation.

Original pull request: #200.
1.1.x
Michal Fotyga 6 years ago committed by Jens Schauder
parent
commit
ba348db81d
No known key found for this signature in database
GPG Key ID: 996B1389BA0721C3
  1. 2
      CI.adoc
  2. 2
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DataAccessStrategy.java
  3. 2
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/IterableOfEntryToMapConverter.java
  4. 10
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/mybatis/MyBatisContext.java
  5. 2
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/config/ConfigurableRowMapperMap.java
  6. 2
      spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/JdbcAggregateTemplateUnitTests.java
  7. 24
      spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/JdbcRepositoryResultSetExtractorIntegrationTests.java
  8. 4
      spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/query/QueryAnnotationHsqlIntegrationTests.java
  9. 2
      spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/support/JdbcRepositoryFactoryBeanUnitTests.java
  10. 4
      src/main/asciidoc/jdbc.adoc

2
CI.adoc

@ -8,7 +8,7 @@ image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-jdbc%2F1.0.x&su
Since this pipeline is purely Docker-based, it's easy to: Since this pipeline is purely Docker-based, it's easy to:
* Debug what went wrong on your local machine. * Debug what went wrong on your local machine.
* Test out a a tweak to your `test.sh` script before sending it out. * Test out a tweak to your `test.sh` script before sending it out.
* Experiment against a new image before submitting your pull request. * Experiment against a new image before submitting your pull request.
All of these use cases are great reasons to essentially run what the CI server does on your local machine. All of these use cases are great reasons to essentially run what the CI server does on your local machine.

2
spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DataAccessStrategy.java

@ -139,7 +139,7 @@ public interface DataAccessStrategy extends RelationResolver {
* passed in matches the number of entities returned. * passed in matches the number of entities returned.
* *
* @param ids the Ids of the entities to load. Must not be {@code null}. * @param ids the Ids of the entities to load. Must not be {@code null}.
* @param domainType the type of entities to laod. Must not be {@code null}. * @param domainType the type of entities to load. Must not be {@code null}.
* @param <T> type of entities to load. * @param <T> type of entities to load.
* @return the loaded entities. Guaranteed to be not {@code null}. * @return the loaded entities. Guaranteed to be not {@code null}.
*/ */

2
spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/IterableOfEntryToMapConverter.java

@ -54,7 +54,7 @@ class IterableOfEntryToMapConverter implements ConditionalConverter, Converter<I
/** /**
* Tries to determine if the {@literal sourceType} can be converted to a {@link Map}. If this can not be determined, * Tries to determine if the {@literal sourceType} can be converted to a {@link Map}. If this can not be determined,
* because the sourceTyppe does not contain information about the element type it returns {@literal true}. * because the sourceType does not contain information about the element type it returns {@literal true}.
* *
* @param sourceType {@link TypeDescriptor} to convert from. * @param sourceType {@link TypeDescriptor} to convert from.
* @param targetType {@link TypeDescriptor} to convert to. * @param targetType {@link TypeDescriptor} to convert to.

10
spring-data-jdbc/src/main/java/org/springframework/data/jdbc/mybatis/MyBatisContext.java

@ -35,16 +35,16 @@ public class MyBatisContext {
private final @Nullable Object instance; private final @Nullable Object instance;
private final @Nullable Identifier identifier; private final @Nullable Identifier identifier;
private final @Nullable Class domainType; private final @Nullable Class domainType;
private final Map<String, Object> additonalValues; private final Map<String, Object> additionalValues;
public MyBatisContext(@Nullable Object id, @Nullable Object instance, @Nullable Class domainType, public MyBatisContext(@Nullable Object id, @Nullable Object instance, @Nullable Class domainType,
Map<String, Object> additonalValues) { Map<String, Object> additionalValues) {
this.id = id; this.id = id;
this.identifier = null; this.identifier = null;
this.instance = instance; this.instance = instance;
this.domainType = domainType; this.domainType = domainType;
this.additonalValues = additonalValues; this.additionalValues = additionalValues;
} }
public MyBatisContext(Identifier identifier, @Nullable Object instance, @Nullable Class<?> domainType) { public MyBatisContext(Identifier identifier, @Nullable Object instance, @Nullable Class<?> domainType) {
@ -53,7 +53,7 @@ public class MyBatisContext {
this.identifier = identifier; this.identifier = identifier;
this.instance = instance; this.instance = instance;
this.domainType = domainType; this.domainType = domainType;
this.additonalValues = Collections.emptyMap(); this.additionalValues = Collections.emptyMap();
} }
/** /**
@ -104,7 +104,7 @@ public class MyBatisContext {
*/ */
@Nullable @Nullable
public Object get(String key) { public Object get(String key) {
return additonalValues.get(key); return additionalValues.get(key);
} }
} }

2
spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/config/ConfigurableRowMapperMap.java

@ -46,7 +46,7 @@ public class ConfigurableRowMapperMap implements RowMapperMap {
} }
/** /**
* Returs a {@link RowMapper} for the given type if such a {@link RowMapper} is present. If an exact match is found * Returns a {@link RowMapper} for the given type if such a {@link RowMapper} is present. If an exact match is found
* that is returned. If not a {@link RowMapper} is returned that produces subtypes of the requested type. If no such * that is returned. If not a {@link RowMapper} is returned that produces subtypes of the requested type. If no such
* {@link RowMapper} is found the method returns {@code null}. * {@link RowMapper} is found the method returns {@code null}.
* *

2
spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/JdbcAggregateTemplateUnitTests.java

@ -88,7 +88,7 @@ public class JdbcAggregateTemplateUnitTests {
} }
@Test // DATAJDBC-378 @Test // DATAJDBC-378
public void findAllByIdWithEmpthListMustReturnEmptyResult() { public void findAllByIdWithEmptyListMustReturnEmptyResult() {
assertThat(template.findAllById(emptyList(), SampleEntity.class)).isEmpty(); assertThat(template.findAllById(emptyList(), SampleEntity.class)).isEmpty();
} }

24
spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/JdbcRepositoryResultSetExtractorIntegrationTests.java

@ -88,19 +88,19 @@ public class JdbcRepositoryResultSetExtractorIntegrationTests {
// NOT saving anything, so DB is empty // NOT saving anything, so DB is empty
assertThat(personRepository.findAllPeopleWithAdresses()).isEmpty(); assertThat(personRepository.findAllPeopleWithAddresses()).isEmpty();
} }
@Test // DATAJDBC-290 @Test // DATAJDBC-290
public void findAllPeopleWithAdressesReturnsOnePersonWithoutAdresses() { public void findAllPeopleWithAddressesReturnsOnePersonWithoutAddresses() {
personRepository.save(new Person(null, "Joe", null)); personRepository.save(new Person(null, "Joe", null));
assertThat(personRepository.findAllPeopleWithAdresses()).hasSize(1); assertThat(personRepository.findAllPeopleWithAddresses()).hasSize(1);
} }
@Test // DATAJDBC-290 @Test // DATAJDBC-290
public void findAllPeopleWithAdressesReturnsOnePersonWithAdresses() { public void findAllPeopleWithAddressesReturnsOnePersonWithAddresses() {
final String personName = "Joe"; final String personName = "Joe";
Person savedPerson = personRepository.save(new Person(null, personName, null)); Person savedPerson = personRepository.save(new Person(null, personName, null));
@ -114,13 +114,13 @@ public class JdbcRepositoryResultSetExtractorIntegrationTests {
MapSqlParameterSource paramsAddress2 = buildAddressParameters(savedPerson.getId(), street2); MapSqlParameterSource paramsAddress2 = buildAddressParameters(savedPerson.getId(), street2);
template.update("insert into address (street, person_id) values (:street, :personId)", paramsAddress2); template.update("insert into address (street, person_id) values (:street, :personId)", paramsAddress2);
List<Person> people = personRepository.findAllPeopleWithAdresses(); List<Person> people = personRepository.findAllPeopleWithAddresses();
assertThat(people).hasSize(1); assertThat(people).hasSize(1);
Person person = people.get(0); Person person = people.get(0);
assertThat(person.getName()).isEqualTo(personName); assertThat(person.getName()).isEqualTo(personName);
assertThat(person.getAdresses()).hasSize(2); assertThat(person.getAddresses()).hasSize(2);
assertThat(person.getAdresses()).extracting(a -> a.getStreet()).containsExactlyInAnyOrder(street1, street2); assertThat(person.getAddresses()).extracting(a -> a.getStreet()).containsExactlyInAnyOrder(street1, street2);
} }
private MapSqlParameterSource buildAddressParameters(Long id, String streetName) { private MapSqlParameterSource buildAddressParameters(Long id, String streetName) {
@ -137,7 +137,7 @@ public class JdbcRepositoryResultSetExtractorIntegrationTests {
@Query( @Query(
value = "select p.id, p.name, a.id addrId, a.street from person p left join address a on(p.id = a.person_id)", value = "select p.id, p.name, a.id addrId, a.street from person p left join address a on(p.id = a.person_id)",
resultSetExtractorClass = PersonResultSetExtractor.class) resultSetExtractorClass = PersonResultSetExtractor.class)
List<Person> findAllPeopleWithAdresses(); List<Person> findAllPeopleWithAddresses();
} }
@Data @Data
@ -146,7 +146,7 @@ public class JdbcRepositoryResultSetExtractorIntegrationTests {
@Id private Long id; @Id private Long id;
private String name; private String name;
private List<Address> adresses; private List<Address> addresses;
} }
@Data @Data
@ -176,13 +176,13 @@ public class JdbcRepositoryResultSetExtractorIntegrationTests {
} }
}); });
if (currentPerson.getAdresses() == null) { if (currentPerson.getAddresses() == null) {
currentPerson.setAdresses(new ArrayList<>()); currentPerson.setAddresses(new ArrayList<>());
} }
long addrId = rs.getLong("addrId"); long addrId = rs.getLong("addrId");
if (!rs.wasNull()) { if (!rs.wasNull()) {
currentPerson.getAdresses().add(new Address(addrId, rs.getString("street"))); currentPerson.getAddresses().add(new Address(addrId, rs.getString("street")));
} }
} }

4
spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/query/QueryAnnotationHsqlIntegrationTests.java

@ -172,7 +172,7 @@ public class QueryAnnotationHsqlIntegrationTests {
} }
@Test // DATAJDBC-175 @Test // DATAJDBC-175
public void executeCustomQueryWithReturnTypeIsNubmer() { public void executeCustomQueryWithReturnTypeIsNumber() {
repository.save(dummyEntity("aaa")); repository.save(dummyEntity("aaa"));
repository.save(dummyEntity("bbb")); repository.save(dummyEntity("bbb"));
@ -200,7 +200,7 @@ public class QueryAnnotationHsqlIntegrationTests {
public void executeCustomQueryWithReturnTypeIsDate() { public void executeCustomQueryWithReturnTypeIsDate() {
// Since Timestamp extends Date the repository returns the Timestamp as it comes from the database. // Since Timestamp extends Date the repository returns the Timestamp as it comes from the database.
// Trying to compare that to an actual Date results in non determistic results, so we have to use an actual // Trying to compare that to an actual Date results in non deterministic results, so we have to use an actual
// Timestamp. // Timestamp.
Date now = new Timestamp(System.currentTimeMillis()); Date now = new Timestamp(System.currentTimeMillis());
assertThat(repository.nowWithDate()).isAfterOrEqualsTo(now); assertThat(repository.nowWithDate()).isAfterOrEqualsTo(now);

2
spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/support/JdbcRepositoryFactoryBeanUnitTests.java

@ -98,7 +98,7 @@ public class JdbcRepositoryFactoryBeanUnitTests {
} }
@Test(expected = IllegalStateException.class) // DATAJDBC-155 @Test(expected = IllegalStateException.class) // DATAJDBC-155
public void afterPropertiesThowsExceptionWhenNoMappingContextSet() { public void afterPropertiesThrowsExceptionWhenNoMappingContextSet() {
factoryBean.setMappingContext(null); factoryBean.setMappingContext(null);
factoryBean.setApplicationEventPublisher(publisher); factoryBean.setApplicationEventPublisher(publisher);

4
src/main/asciidoc/jdbc.adoc

@ -309,7 +309,7 @@ public class EmbeddedEntity {
String name; String name;
} }
---- ----
<1> ``Null``s `embeddedEntity` if `name` in `null`. Use `USE_EMPTY` to instanciate `embeddedEntity` with a potential `null` value for the `name` property. <1> ``Null``s `embeddedEntity` if `name` in `null`. Use `USE_EMPTY` to instantiate `embeddedEntity` with a potential `null` value for the `name` property.
==== ====
If you need a value object multiple times in an entity, this can be achieved with the optional `prefix` element of the `@Embedded` annotation. If you need a value object multiple times in an entity, this can be achieved with the optional `prefix` element of the `@Embedded` annotation.
@ -317,7 +317,7 @@ This element represents a prefix and is prepend for each column name in the embe
[TIP] [TIP]
==== ====
Make use of the shortcuts `@Embedded.Nullable` & `@Embedded.Empty` for `@Embedded(onEmpty = USE_NULL)` and `@Embedded(onEmpty = USE_EMPTY)` to reduce verbositility and simultaneously set JSR-305 `@javax.annotation.Nonnull` accordingly. Make use of the shortcuts `@Embedded.Nullable` & `@Embedded.Empty` for `@Embedded(onEmpty = USE_NULL)` and `@Embedded(onEmpty = USE_EMPTY)` to reduce verbosity and simultaneously set JSR-305 `@javax.annotation.Nonnull` accordingly.
[source, java] [source, java]
---- ----

Loading…
Cancel
Save