SlideShare une entreprise Scribd logo
1  sur  43
Télécharger pour lire hors ligne
│©2022 VMware, Inc.
Modern Persistence
With Spring Data 3
People Standing on Platform of a Subway Station - Niklas Jeromin - https://www.pexels.com/
Baseline
Java 17
Framework 6
Jakarta EE 9
Baseline
Framework 6
/*
* Extend Future with the capability to accept completion callbacks.
* @deprecated as of 6.0, in favor of CompletableFuture
*/
@Deprecated(since = "6.0")
public interface ListenableFuture<T> extends Future<T> { ... }
future.addCallback(
it -> { ... },
exception -> { ... }
);
future.whenComplete(
(it, exception) -> { ... }
);
Minimum Baseline
Java 17
Framework 6
Jakarta EE 9
/*
* Extend Future with the capability to accept completion callbacks.
* @deprecated as of 6.0, in favor of CompletableFuture
*/
@Deprecated(since = "6.0")
public interface ListenableFuture<T> extends Future<T> { ... }
future.addCallback(it -> { ... }, exception -> { ... });
future.whenComplete((it, exception) -> { ... });
RxJava1 & RxJava2 support
discontinued
import io.reactivex.Maybe;
interface RxPersonRepository extends RxJava2CrudRepository {
Maybe<Person> findPersonById(Long id);
}
import io.reactivex.rxjava3.core.Maybe;
interface RxPersonRepository extends RxJava3CrudRepository {
Maybe<Person> findPersonById(Long id);
}
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
Baseline
Jakarte EE 9
-Drewrite.activeRecipes=org.openrewrite.java.migrate.JavaxMigrationToJakarta
$> java -jar spring-boot-migrator.jar
jee-project:> apply initialize-spring-boot-migration
SBM
$> find * -name '*.java' | xargs perl -pi -e "s/javax.persistence./jakarta.persistence./g"
Bash
OSS Support
extended
In October 2022, the Apache Geode project failed to secure at
least three voting members on the PMC required to maintain
and manage the Apache Geode Project, after which it was
moved to the foundations Attic.
Spring Data for Apache Geode
discontinued
Spring Data for Apache Geode
digital mixer, public domain cc0 - https://www.rawpixel.com/image/5920690
Modern Persistence with Spring Data 3
Modern Persistence with Spring Data 3
jar
native - image
Modern Persistence with Spring Data 3
@Bean
public MongoManagedTypes managedTypes() {
return MongoManagedTypes.from(Customer.class, Order.class);
}
From Spring Native to Boot 3
Thursday, Jan 26 ‘23
Modern Persistence with Spring Data 3
Micrometer
integtration
Apache Cassandra
MongoDB
Redis
Traces Metrics
Logs
Observability of Your Application
Wednesday, Jan 25 ‘23
Modern Persistence with Spring Data 3
management.metrics.mongo.command.enabled=false
Observability
Data MongoDB
< 3.1
@SpringBootApplication
public class SpringDataMongodbObservabilityApplication {
@Bean
CommandLineRunner initDatabase(EmployeeRepository repository, ObservationRegistry registry) {
// ...
}
@Bean
MongoClientSettingsBuilderCustomizer mongoContextProvider(ObservationRegistry registry) {
return (clientSettingsBuilder) ->
clientSettingsBuilder.contextProvider(ContextProviderFactory.create(registry))
.addCommandListener(new MongoObservationCommandListener(registry));
}
}
Observability
Data MongoDB
@SpringBootApplication
public class SpringDataMongodbObservabilityApplication {
@Bean
CommandLineRunner initDatabase(EmployeeRepository repository, ObservationRegistry registry) {
return args -> {
Observation.createNotStarted("init-database", registry).observe(() -> {
repository.save(new Employee("Frodo", "ring bearer"));
repository.save(new Employee("Bilbo", "burglar"));
});
};
}
@Bean
MongoClientSettingsBuilderCustomizer mongoContextProvider(ObservationRegistry registry) {
return (clientSettingsBuilder) ->
clientSettingsBuilder.contextProvider(ContextProviderFactory.create(registry))
.addCommandListener(new MongoObservationCommandListener(registry));
}
}
Observability
Data MongoDB
Modern Persistence with Spring Data 3
Data JPA
@Query(value = "select u.* from User u", queryRewriter = TenantQRW.class)
List<User> findUsers(Pageable pageable);
static class TenantQRW implements QueryRewriter {
@Override
public String rewrite(String query, Sort sort) {
return query + " WHERE u.tenantId = " + context.getTenantId();
}
}
Data JPA
Query Rewriter
Data JDBC
@Query("SELECT * FROM person WHERE username = :#{ principal?.username }")
Person findActiveUser();
Data JDBC
SpEL Expressions
@EnableJdbcRepositories
static class AppConfiguration {
// ...
@Bean
BeforeConvertCallback<Person> idGenerator() {
return p -> p.withId(UUID.randomUUID());
}
}
Data JDBC
Lifecycle Events & Callbacks
Data JDBC
Operation Batching
A B
Data JDBC
Operation Batching
A B
Data MongoDB
template.createView("firstYears", Student.class, match(where("year").is(1)));
Data MongoDB
Views
Person existing = template.update(Person.class)
.matching(where("firstname").is("Harry"))
.apply(new Update().inc("age", 1))
.findAndModifyValue();
@Update("{ '$inc' : { 'age' : ?1 } }")
Person findAndIncrementAgeByFirstname(String firstname, int increment);
Data MongoDB
findAndModify
Data MongoDB
Aggregations
Aggregation.stage(search(exists(fieldPath("age"))));
Data MongoDB
Aggregations
spring-data
mongodb-driver
Data Redis
public class User {
@JsonView(Basic.class)
private int id;
@JsonView(Basic.class)
private String name;
@JsonView(Detailed.class)
private String email;
}
Data Redis
Object Mapping
new GenericJackson2JsonRedisSerializer(objectMapper, JacksonObjectReader.create(),
(mapper, source) -> mapper.writerWithView(Basic.class).writeValueAsBytes(source)
);
What’s next?
Single Select
queries
A
B C
⋈
naïve join
Single Select
queries
A
B C
⋈
analytic join
public class Person {
String id;
String name;
@EncryptedField(algorithm = SHA_512_Deterministic)
String ssn;
@EncryptedField(algorithm = SHA_512_Random, altKeyName = "secretKey")
String wallet;
@EncryptedField(algorithm = SHA_512_Random, altKeyName = "/name")
Address address;
}
Encryption
client side
public class Person {
String id;
String name;
@EncryptedField(algorithm = SHA_512_Deterministic)
String ssn;
@EncryptedField(algorithm = SHA_512_Random, altKeyName = "secretKey")
String wallet;
@EncryptedField(algorithm = SHA_512_Random, altKeyName = "/name")
Address address;
}
Encryption
client side
{
"_id": "ff3-4567-ee",
"name": "chris",
"ssn": {
"$binary": {
"base64": "AVpT0rwbK0P
"subType": "06"
}
},
"wallet": {
"$binary": {
"base64": "AlpT0rwbK0P
"subType": "06"
}
},
"address": {
"$binary": {
"base64": "+T3C+n4HOBF
"subType": "06"
}
},
"_class": ”example.Person"
}
Modern Persistence with Spring Data 3

Contenu connexe

Plus de VMware Tanzu

Plus de VMware Tanzu (20)

Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
 
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
 
tanzu_developer_connect.pptx
tanzu_developer_connect.pptxtanzu_developer_connect.pptx
tanzu_developer_connect.pptx
 
Tanzu Virtual Developer Connect Workshop - French
Tanzu Virtual Developer Connect Workshop - FrenchTanzu Virtual Developer Connect Workshop - French
Tanzu Virtual Developer Connect Workshop - French
 
Tanzu Developer Connect Workshop - English
Tanzu Developer Connect Workshop - EnglishTanzu Developer Connect Workshop - English
Tanzu Developer Connect Workshop - English
 
Virtual Developer Connect Workshop - English
Virtual Developer Connect Workshop - EnglishVirtual Developer Connect Workshop - English
Virtual Developer Connect Workshop - English
 
Tanzu Developer Connect - French
Tanzu Developer Connect - FrenchTanzu Developer Connect - French
Tanzu Developer Connect - French
 
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
 
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring BootSpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
 
SpringOne Tour: The Influential Software Engineer
SpringOne Tour: The Influential Software EngineerSpringOne Tour: The Influential Software Engineer
SpringOne Tour: The Influential Software Engineer
 
SpringOne Tour: Domain-Driven Design: Theory vs Practice
SpringOne Tour: Domain-Driven Design: Theory vs PracticeSpringOne Tour: Domain-Driven Design: Theory vs Practice
SpringOne Tour: Domain-Driven Design: Theory vs Practice
 
SpringOne Tour: Spring Recipes: A Collection of Common-Sense Solutions
SpringOne Tour: Spring Recipes: A Collection of Common-Sense SolutionsSpringOne Tour: Spring Recipes: A Collection of Common-Sense Solutions
SpringOne Tour: Spring Recipes: A Collection of Common-Sense Solutions
 
SpringOne Tour: Doing Progressive Delivery with your Team
SpringOne Tour: Doing Progressive Delivery with your TeamSpringOne Tour: Doing Progressive Delivery with your Team
SpringOne Tour: Doing Progressive Delivery with your Team
 
SpringOne Tour: Make the Right Thing the Obvious Thing: The Journey to Intern...
SpringOne Tour: Make the Right Thing the Obvious Thing: The Journey to Intern...SpringOne Tour: Make the Right Thing the Obvious Thing: The Journey to Intern...
SpringOne Tour: Make the Right Thing the Obvious Thing: The Journey to Intern...
 
SpringOne Tour: An Introduction to Azure Spring Apps Enterprise
SpringOne Tour: An Introduction to Azure Spring Apps EnterpriseSpringOne Tour: An Introduction to Azure Spring Apps Enterprise
SpringOne Tour: An Introduction to Azure Spring Apps Enterprise
 
SpringOne Tour: 10 Practical Tips for Building Native and Serverless Spring A...
SpringOne Tour: 10 Practical Tips for Building Native and Serverless Spring A...SpringOne Tour: 10 Practical Tips for Building Native and Serverless Spring A...
SpringOne Tour: 10 Practical Tips for Building Native and Serverless Spring A...
 
SpringOne Tour: Spring Boot 3 and Beyond
SpringOne Tour: Spring Boot 3 and BeyondSpringOne Tour: Spring Boot 3 and Beyond
SpringOne Tour: Spring Boot 3 and Beyond
 
SpringOne Tour 2023: Let's Get Streaming! A Guide to Orchestrating Spring Clo...
SpringOne Tour 2023: Let's Get Streaming! A Guide to Orchestrating Spring Clo...SpringOne Tour 2023: Let's Get Streaming! A Guide to Orchestrating Spring Clo...
SpringOne Tour 2023: Let's Get Streaming! A Guide to Orchestrating Spring Clo...
 
Tanzu Developer Connect | Public Sector | March 29, 2023.pdf
Tanzu Developer Connect | Public Sector | March 29, 2023.pdfTanzu Developer Connect | Public Sector | March 29, 2023.pdf
Tanzu Developer Connect | Public Sector | March 29, 2023.pdf
 
Simplify and Scale Enterprise Spring Apps in the Cloud | March 23, 2023
Simplify and Scale Enterprise Spring Apps in the Cloud | March 23, 2023Simplify and Scale Enterprise Spring Apps in the Cloud | March 23, 2023
Simplify and Scale Enterprise Spring Apps in the Cloud | March 23, 2023
 

Dernier

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Modern Persistence with Spring Data 3