Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
<parent>
<groupId>org.springframework.data.build</groupId>
<artifactId>spring-data-parent</artifactId>
<version>3.5.0-RC1</version>
<version>3.5.1</version>
</parent>

<properties>
<dist.id>spring-data-jdbc</dist.id>
<springdata.commons>3.5.0-RC1</springdata.commons>
<springdata.commons>3.5.1</springdata.commons>
<liquibase.version>4.21.1</liquibase.version>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>

Expand Down
2 changes: 1 addition & 1 deletion spring-data-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jdbc</artifactId>
<version>3.5.0-RC1</version>
<version>${springdata.commons}</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.springframework.data.jdbc;

import org.assertj.core.api.SoftAssertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.data.auditing.config.AuditingHandlerBeanDefinitionParser;

Expand All @@ -34,6 +35,7 @@
*
* @author Jens Schauder
*/
@Disabled("Disabled because of JdbcArrayColumns and Dialect cycle to be resolved in 4.0")
public class DependencyTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@
import java.util.stream.IntStream;
import java.util.stream.Stream;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
Expand Down Expand Up @@ -60,6 +61,7 @@
import org.springframework.data.relational.core.mapping.MappedCollection;
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
import org.springframework.data.relational.core.mapping.Table;
import org.springframework.data.relational.core.mapping.event.BeforeConvertCallback;
import org.springframework.data.relational.core.query.Criteria;
import org.springframework.data.relational.core.query.CriteriaDefinition;
import org.springframework.data.relational.core.query.Query;
Expand Down Expand Up @@ -236,7 +238,25 @@ void findAllByQuery() {
Query query = Query.query(criteria);
Iterable<SimpleListParent> reloadedById = template.findAll(query, SimpleListParent.class);

assertThat(reloadedById).extracting(e -> e.id, e -> e.content.size()).containsExactly(tuple(two.id, 2));
assertThat(reloadedById) //
.extracting(e -> e.id, e-> e.name, e -> e.content.size()) //
.containsExactly(tuple(two.id, two.name, 2));
}

@Test // GH-1803
void findAllByQueryWithColumns() {

template.save(SimpleListParent.of("one", "one_1"));
SimpleListParent two = template.save(SimpleListParent.of("two", "two_1", "two_2"));
template.save(SimpleListParent.of("three", "three_1", "three_2", "three_3"));

CriteriaDefinition criteria = CriteriaDefinition.from(Criteria.where("id").is(two.id));
Query query = Query.query(criteria).columns("id");
Iterable<SimpleListParent> reloadedById = template.findAll(query, SimpleListParent.class);

assertThat(reloadedById) //
.extracting(e -> e.id, e-> e.name, e -> e.content.size()) //
.containsExactly(tuple(two.id, null, 2));
}

@Test // GH-1601
Expand Down Expand Up @@ -1373,6 +1393,22 @@ void mapWithEnumKey() {
assertThat(enumMapOwners).containsExactly(enumMapOwner);
}

@Test // GH-2064
void saveAllBeforeConvertCallback() {

BeforeConvertCallbackForSaveBatch first = new BeforeConvertCallbackForSaveBatch("first");
BeforeConvertCallbackForSaveBatch second = new BeforeConvertCallbackForSaveBatch("second");
BeforeConvertCallbackForSaveBatch third = new BeforeConvertCallbackForSaveBatch("third");

template.saveAll(List.of(first, second, third));

List<BeforeConvertCallbackForSaveBatch> allEntriesInTable = template
.findAll(BeforeConvertCallbackForSaveBatch.class);

assertThat(allEntriesInTable).hasSize(3).extracting(BeforeConvertCallbackForSaveBatch::getName)
.containsExactlyInAnyOrder("first", "second", "third");
}

@Test // GH-1684
void oneToOneWithIdenticalIdColumnName() {

Expand Down Expand Up @@ -2184,6 +2220,31 @@ public Short getVersion() {
}
}

@Table("BEFORE_CONVERT_CALLBACK_FOR_SAVE_BATCH")
static class BeforeConvertCallbackForSaveBatch {

@Id
private String id;

private String name;

public BeforeConvertCallbackForSaveBatch(String name) {
this.name = name;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getName() {
return name;
}
}

@Table("VERSIONED_AGGREGATE")
static class AggregateWithPrimitiveShortVersion extends VersionedAggregate {

Expand Down Expand Up @@ -2214,12 +2275,14 @@ static class WithIdOnly {

@Table
static class WithInsertOnly {

@Id Long id;
@InsertOnlyProperty String insertOnly;
}

@Table
static class MultipleCollections {

@Id Long id;
String name;
List<ListElement> listElements = new ArrayList<>();
Expand Down Expand Up @@ -2271,9 +2334,17 @@ TestClass testClass() {
}

@Bean
JdbcAggregateOperations operations(ApplicationEventPublisher publisher, RelationalMappingContext context,
BeforeConvertCallback<BeforeConvertCallbackForSaveBatch> callback() {
return aggregate -> {
aggregate.setId(UUID.randomUUID().toString());
return aggregate;
};
}

@Bean
JdbcAggregateOperations operations(ApplicationContext applicationContext, RelationalMappingContext context,
DataAccessStrategy dataAccessStrategy, JdbcConverter converter) {
return new JdbcAggregateTemplate(publisher, context, converter, dataAccessStrategy);
return new JdbcAggregateTemplate(applicationContext, context, converter, dataAccessStrategy);
}
}

Expand All @@ -2285,5 +2356,10 @@ static class JdbcAggregateTemplateIntegrationTests extends AbstractJdbcAggregate
static class JdbcAggregateTemplateSingleQueryLoadingIntegrationTests
extends AbstractJdbcAggregateTemplateIntegrationTests {

@Disabled
@Override
void findAllByQueryWithColumns() {
super.findAllByQueryWithColumns();
}
}
}
Loading