Confidential │ ©2021 VMware, Inc.
Spring Data JDBC
Beyond the Obvious
Jens Schauder (he/him)
Spring Data
Year 2 of the Pandemic
Confidential │ ©2021 VMware, Inc. 2
This presentation may contain product features or functionality that are currently under
development.
This overview of new technology represents no commitment from VMware to deliver these
features in any generally available product.
Features are subject to change, and must not be included in contracts, purchase orders, or
sales agreements of any kind.
Technical feasibility and market demand will affect final delivery.
Pricing and packaging for any new features/functionality/technology discussed or
presented, have not been determined.
The information in this presentation is for informational purposes only and may not be incorporated into any contract. There is no
commitment or obligation to deliver any items presented herein.
Disclaimer
Confidential │ ©2021 VMware, Inc.
Spring Data JDBC
Confidential │ ©2021 VMware, Inc. 4
Spring Data
Confidential │ ©2021 VMware, Inc. 5
Relational Databases
Confidential │ ©2021 VMware, Inc. 6
Strong Aggregates
Confidential │ ©2021 VMware, Inc.
Challenges
Confidential │ ©2021 VMware, Inc. 8
User Defined IDs
Confidential │ ©2021 VMware, Inc. 9
User Defined IDs
Use
• JdbcAggregateTemplate.insert
• Or a BeforeSaveCallback
Confidential │ ©2021 VMware, Inc. 10
JSON / Custom Conversions
Confidential │ ©2021 VMware, Inc. 11
JSON / Custom Conversions
• Use a custom type
• Register custom converters
• Don’t forget @ReadingConverter /
@WritingConverter
Confidential │ ©2021 VMware, Inc. 12
Bidirectional Relationships
Confidential │ ©2021 VMware, Inc. 13
Bidirectional Relationships (internal)
Set the backreference whenever adding an
inner entity.
Confidential │ ©2021 VMware, Inc. 14
Bidirectional Relationships (external)
Use a custom query on the repository.
Confidential │ ©2021 VMware, Inc. 15
Caching
Confidential │ ©2021 VMware, Inc. 16
Caching
Use Springs existing caching abstraction on
the repository.
Confidential │ ©2021 VMware, Inc. 17
Eager Loading References
Confidential │ ©2021 VMware, Inc. 18
Eager Loading References
Create an entity defining the required
combination of aggregates (or their pieces)
Use a dedicated repository or custom
queries to load it.
You may want to “persist” the query as a
database view.
Confidential │ ©2021 VMware, Inc. 19
Resources
Source: https://github.com/schauder/talk-beyond
SD JDBC: https://github.com/spring-projects/spring-data-jdbc
Required Reading:https://spring.io/blog/2018/09/24/spring-data-
jdbc-references-and-aggregates
SO: https://stackoverflow.com/questions/tagged/spring-data-jdbc
Twitter: https://twitter.com/jensschauder
Confidential │ ©2021 VMware, Inc. 20
Questions?

Spring Data JDBC: Beyond the Obvious

  • 1.
    Confidential │ ©2021VMware, Inc. Spring Data JDBC Beyond the Obvious Jens Schauder (he/him) Spring Data Year 2 of the Pandemic
  • 2.
    Confidential │ ©2021VMware, Inc. 2 This presentation may contain product features or functionality that are currently under development. This overview of new technology represents no commitment from VMware to deliver these features in any generally available product. Features are subject to change, and must not be included in contracts, purchase orders, or sales agreements of any kind. Technical feasibility and market demand will affect final delivery. Pricing and packaging for any new features/functionality/technology discussed or presented, have not been determined. The information in this presentation is for informational purposes only and may not be incorporated into any contract. There is no commitment or obligation to deliver any items presented herein. Disclaimer
  • 3.
    Confidential │ ©2021VMware, Inc. Spring Data JDBC
  • 4.
    Confidential │ ©2021VMware, Inc. 4 Spring Data
  • 5.
    Confidential │ ©2021VMware, Inc. 5 Relational Databases
  • 6.
    Confidential │ ©2021VMware, Inc. 6 Strong Aggregates
  • 7.
    Confidential │ ©2021VMware, Inc. Challenges
  • 8.
    Confidential │ ©2021VMware, Inc. 8 User Defined IDs
  • 9.
    Confidential │ ©2021VMware, Inc. 9 User Defined IDs Use • JdbcAggregateTemplate.insert • Or a BeforeSaveCallback
  • 10.
    Confidential │ ©2021VMware, Inc. 10 JSON / Custom Conversions
  • 11.
    Confidential │ ©2021VMware, Inc. 11 JSON / Custom Conversions • Use a custom type • Register custom converters • Don’t forget @ReadingConverter / @WritingConverter
  • 12.
    Confidential │ ©2021VMware, Inc. 12 Bidirectional Relationships
  • 13.
    Confidential │ ©2021VMware, Inc. 13 Bidirectional Relationships (internal) Set the backreference whenever adding an inner entity.
  • 14.
    Confidential │ ©2021VMware, Inc. 14 Bidirectional Relationships (external) Use a custom query on the repository.
  • 15.
    Confidential │ ©2021VMware, Inc. 15 Caching
  • 16.
    Confidential │ ©2021VMware, Inc. 16 Caching Use Springs existing caching abstraction on the repository.
  • 17.
    Confidential │ ©2021VMware, Inc. 17 Eager Loading References
  • 18.
    Confidential │ ©2021VMware, Inc. 18 Eager Loading References Create an entity defining the required combination of aggregates (or their pieces) Use a dedicated repository or custom queries to load it. You may want to “persist” the query as a database view.
  • 19.
    Confidential │ ©2021VMware, Inc. 19 Resources Source: https://github.com/schauder/talk-beyond SD JDBC: https://github.com/spring-projects/spring-data-jdbc Required Reading:https://spring.io/blog/2018/09/24/spring-data- jdbc-references-and-aggregates SO: https://stackoverflow.com/questions/tagged/spring-data-jdbc Twitter: https://twitter.com/jensschauder
  • 20.
    Confidential │ ©2021VMware, Inc. 20 Questions?