#380 - Adapt to changed API.
New CustomConversions API. More limited access strategies introduced through the immutable support. Fixed dependencies of the r2dbc example.
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package example.springdata.jdbc.basics.aggregate;
|
||||
|
||||
import static java.util.Arrays.*;
|
||||
|
||||
import java.sql.Clob;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
@@ -25,10 +27,12 @@ import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.data.convert.CustomConversions;
|
||||
import org.springframework.data.jdbc.core.convert.JdbcCustomConversions;
|
||||
import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories;
|
||||
import org.springframework.data.relational.core.mapping.ConversionCustomizer;
|
||||
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
|
||||
import org.springframework.data.jdbc.repository.config.JdbcConfiguration;
|
||||
import org.springframework.data.relational.core.mapping.NamingStrategy;
|
||||
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
|
||||
import org.springframework.data.relational.core.mapping.event.BeforeSaveEvent;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
@@ -37,7 +41,7 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
@Configuration
|
||||
@EnableJdbcRepositories
|
||||
public class AggregateConfiguration {
|
||||
public class AggregateConfiguration extends JdbcConfiguration {
|
||||
|
||||
final AtomicInteger id = new AtomicInteger(0);
|
||||
|
||||
@@ -101,10 +105,10 @@ public class AggregateConfiguration {
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ConversionCustomizer conversionCustomizer() {
|
||||
@Override
|
||||
protected CustomConversions jdbcCustomConversions() {
|
||||
|
||||
return conversions -> conversions.addConverter(new Converter<Clob, String>() {
|
||||
return new JdbcCustomConversions(asList(new Converter<Clob, String>() {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@@ -120,6 +124,6 @@ public class AggregateConfiguration {
|
||||
throw new IllegalStateException("Failed to convert CLOB to String.", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ public class LegoSet {
|
||||
private Manual manual;
|
||||
|
||||
// You can build multiple models from one LegoSet
|
||||
@AccessType(Type.FIELD)
|
||||
private final Map<String, Model> models = new HashMap<>();
|
||||
|
||||
// conversion for custom types currently has to be done through getters/setter + marking the underlying property with
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.jdbc.core.DataAccessStrategy;
|
||||
import org.springframework.data.jdbc.mybatis.MyBatisDataAccessStrategy;
|
||||
import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories;
|
||||
import org.springframework.data.relational.core.conversion.RelationalConverter;
|
||||
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
|
||||
@@ -32,8 +33,8 @@ import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
public class MyBatisConfiguration {
|
||||
|
||||
@Bean
|
||||
DataAccessStrategy defaultDataAccessStrategy(RelationalMappingContext context,
|
||||
DataAccessStrategy defaultDataAccessStrategy(RelationalMappingContext context, RelationalConverter converter,
|
||||
NamedParameterJdbcOperations operations, SqlSession sqlSession) {
|
||||
return MyBatisDataAccessStrategy.createCombinedAccessStrategy(context, operations, sqlSession);
|
||||
return MyBatisDataAccessStrategy.createCombinedAccessStrategy(context, converter, operations, sqlSession);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +1,65 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.data.examples</groupId>
|
||||
<artifactId>spring-data-jdbc-examples</artifactId>
|
||||
<version>2.0.0.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>spring-data-r2dbc</artifactId>
|
||||
|
||||
<properties>
|
||||
<reactor-bom.version>Californium-BUILD-SNAPSHOT</reactor-bom.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-jdbc</artifactId>
|
||||
<version>1.0.0.r2dbc-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.r2dbc</groupId>
|
||||
<artifactId>r2dbc-postgresql</artifactId>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.projectreactor</groupId>
|
||||
<artifactId>reactor-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.data.examples</groupId>
|
||||
<artifactId>spring-data-jdbc-examples</artifactId>
|
||||
<version>2.0.0.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>spring-data-r2dbc</artifactId>
|
||||
|
||||
<name>Spring Data JDBC - Demonstrating reactive repositories with R2DBC</name>
|
||||
|
||||
<properties>
|
||||
<reactor-bom.version>Californium-BUILD-SNAPSHOT</reactor-bom.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-jdbc</artifactId>
|
||||
<version>1.0.0.r2dbc-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.r2dbc</groupId>
|
||||
<artifactId>r2dbc-spi</artifactId>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.projectreactor</groupId>
|
||||
<artifactId>reactor-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.r2dbc</groupId>
|
||||
<artifactId>r2dbc-postgresql</artifactId>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.projectreactor</groupId>
|
||||
<artifactId>reactor-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.projectreactor.ipc</groupId>
|
||||
<artifactId>reactor-netty</artifactId>
|
||||
<version>0.7.7.RELEASE</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.projectreactor.addons</groupId>
|
||||
<artifactId>reactor-extra</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package example.springdata.r2dbc.basics;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Value;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
@@ -22,7 +24,8 @@ import org.springframework.data.annotation.Id;
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@Value
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
class Customer {
|
||||
@Id Integer id;
|
||||
String firstname, lastname;
|
||||
|
||||
Reference in New Issue
Block a user