SlideShare a Scribd company logo
1 of 49
Managing Data in
Jakarta EE
Applications
Who am I?
Buhake Sindi
● Senior Full Stack Java Architect &
Engineer/Developer & Consultant
● Over 17+ years in Enterprise Java
development
● Founded Sindi Technologies (Pty) Ltd
● Founded Devoxx4Kids South Africa
(NPO)
● Jakarta EE Ambassador
● Blogger (DZone Core Member)
● Runner, Beat Maker, Podcaster?
Where can you find me?
https://linktr.ee/theEliteGentleman
buhake@gmail.com
www.sindi.co.za
X: @EliteGentleman
Also
Table of contents
Handling data in
the early days
Isolating data
from your
application
Repository
Pattern in
current Jakarta
EE release
Repository in
future release of
Jakarta EE
01 02
03 04
Table of contents
Demo
examples
Q&A
05
06
Handling data in
the early days…
01
Early days…
Monolithic architecture
Vendor-specific APIs
All components (presentation,
business & data access) were tightly
integrated into a single deployment
unit.
Early Java EE specifications were not
as standardized as today. App servers
provided their own specific APIs,
making applications tightly coupled to
the specific application server.
Enterprise Java
Beans (EJBs)
Early versions of EJBs (particularly EJB 2.x)
heavily depended on implementation of EJB
specific interfaces.
Entity Bean was introduced to represent
persistent data maintained in the database.
● Beans were defined to the persistence
management (BMP or CMP).
Difficult to maintain, less flexible &
portable (as it heavily relied on application
server implementation of EJBs)
Challenges…
Limited Separation of concerns
Limited Dependency Injection
Business logic, presentation and
data access were often mixed
Tight integration with JNDI. Also heavy
reliance of XML deployment descriptors
Tight coupling
Limited support for POJOs. Limited code
reusability. Difficulty in testing &
providing mocks.
Big shift to
Enterprise
Application
Architecture,
frameworks and
specifications
EAA and frameworks
Use of Plain-Old-Java-Objects (POJO),
Plain-Old-Java-Interfaces (POJI)
● Specification: Java Data Objects (JDO)
● Data Access Objects (DAO)
● Frameworks: iBatis/myBatis, TopLink,
jOOQ
● ORM: Hibernate
What’s your flavour? Thus, a needed
vendor-agnostic standardisation was
needed for EAA.
Advantages
Portability
Providing a level of
abstraction that is portable
across different data stores.
Consistent API
Standardized API for
interacting with DBs can
help simplify learning curve
for developers & bring
uniform coding style.
Testability
Using POJO, POJI & DI it’s
easier to write unit tests for
business logic.
Separation of
concerns
Isolation of data access
and persistence from
the business logic
Challenges
Performance
Overheads
Depending on specific
implementations and
configurations
Learning Curve
For developers who are new
to these concepts.
Boilerplate code
Implementation of various
framework may introduce
boilerplate code for CRUD
Limited industry
adoption
Various frameworks took
widespread adoptions
compared to other
frameworks
Further Challenges
Vendor focused
Some queries may result
in vendor specific
queries.
Lack of support
for NoSQL DBs
Debugging &
Profiling
Especially with
generated SQL queries
Tight coupling
E.g. change of DB
Schema
Isolating data from
your application
02
Purpose
To separate the data layer and
data access logic from the rest
of your application components.
Key aspects and principles
● Separation of concerns: Keep data access logic separate from the business logic.
● Testability: Make your data access logic easier to write unit test for your business
logic.
● Encapsulation: Hide the details of data storage and retrieval within data access layer.
● Abstraction: Make use of abstract classes and interfaces to define the contract
between the data access layer and the rest of the applications.
● Data Access Layer: Encapsulate all interactions with Data Access Logic.
● Interfaces for Data Access: Clean and well-defined contract for data access
operations (CRUD).
● Use of Design Pattern: DAO / Repository pattern to structure and isolate data access
logic.
● Dependency Injection: Business Logic should depend on Data Access Logic through
abstraction.
● ORM: Usage of JPA/Hibernate allows interactions through POJOs, while abstracting
database interactions.
The Repository pattern
Meets all aspects and principles of data
isolation:
● Data Access Layer.
● Interfaces for Data Access.
● Use of design pattern (also, caching
with strategy pattern?);
● Provides abstraction and loose-
coupling between data access and
rest of your application.
Data
Support many data stores
Support of DI
Relational DBs (JDBC, JPA, Hibernate
Session), NoSQL (MongoDB, Redis,
Cassandra)
Through CDI extensions
Query Methods
Via @Query or Criteria APIs
Repository abstraction
Via interfaces: JpaRepository (for JPA),
CassandraRepository (Cassandra), etc.
Repository Pattern
in current Jakarta
EE release
03
Key aspects
Injectable
With Jakarta CDI @Inject
Testable
Either with jUnit, Mockito, Testcontainers, etc.
Abstractable
Encapsulate Data Access Layer & still
integrate with ORM / JPA, JDBC, etc.
Repository abstraction
Via Repository interface(s)
Deltaspike Data
Support many data stores
Support of DI
JPA centric and relational databases.
No NoSQL support.
Through CDI extensions
Query Methods
Via @Query module (with JPQL
queries)
Repository abstraction
Via @Repository annotation on repository
interface (that extends EntityRepository)
Custom
approach
Best of both Spring Data and Deltaspike Data approach
Domain object
(I) Entity
(I) IdentifiableEntity<ID>
(A) JPAEntity<ID>
(I) CreatedTimestamp
(I) LastModifiedTimestamp
(I) SoftDeletedTimestamp
Domain Entity
Domain objects represent the entities or
business objects in the application's
domain. The repository is responsible for
persisting and retrieving these domain
objects. The use of domain objects
ensures that the data access layer
aligns with the application's business
logic.
Repository
(I) DataRepository<E>
(I) CrudRepository<E, ID> (I) SpecificationRepository
(I) MicrostreamRepository
(I) JPARepository
(I) Specification<E>
(I) CassandraRepository
(A) AbstractJPARepository
The repository pattern is the design pattern, used in software development to create an
abstraction layer between the application’s business logic and the data access code responsible for
interacting with the database or other data sources.
Here’s key component we’ve implemented for our Repository Pattern:
• Repository interface: At the core of the Repository pattern is the interface that defines a
sets of methods for interacting with the data. Each interface abstracts away the data and is
defined for the specific domain entity.
• Super interface: DataRepository
• Sub interface: CrudRepository – Common database operations.
Repository key components
• Concrete Repository implementation: The repository interface
is implemented by a concrete class that provides that actual
implementation of that data access logic. This class interacts
with the underlying data store to execute the defined
operations.
Repository key components
Making CDI injectable
@Repository annotation
A CDI Stereotype annotation that
makes the class a CDI bean when CDI
is available.
The repository implementation must
be made available via the
@jakarta.inject.Inject annotation.
1. Stateless repository: Can inherit state & transactions from
business services (EJB 3.x)
2. Reduced boilerplate code: Abstract classes have implemented
all common database operations.
3. Entity association: E.g., JPARepository is strongly linked to
JPAEntity
Other features
1. Repository interface allows us to create mock implementations
to be used for testing.
2. Suitable for jUnit, Mockito tests.
Testing
Repository in
future release
of Jakarta EE
04
Jakarta Data
Jakarta Data defines core APIs
for the Jakarta EE platform
allowing applications and
other Jakarta EE components
to explore the benefits of easy
access to data technologies
such as relational and non-
relational databases, cloud-
based data services, and so
on.
Goals:
1. Increase productivity performing common database operations.
2. Rich Object Mapping integrated.
3. Define Repositories.
Still under development:
1. Release will support Jakarta EE 11
2. Specification: https://jakarta.ee/specifications/data/1.0/data-
1.0.0-m1
Jakarta Data 1.0
Features:
1. @Repository
2. @Query
3. @Insert, @Update, @Delete
4. @Lifecycle
5. Stateless Repository
6. Built-in interfaces
Jakarta Data 1.0
Currently:
1. In beta on OpenLiberty Beta (23.0.0.12-beta)
2. Include data-1.0 as feature in server.xml
Jakarta Data 1.0
Demo
examples
05
Q&A
Thank you!
Do you have any questions?
buhake@gmail.com
www.sindi.co.za

More Related Content

Similar to Managing Data in Jakarta EE Applications

2008_478_Lyons_ppt.ppt
2008_478_Lyons_ppt.ppt2008_478_Lyons_ppt.ppt
2008_478_Lyons_ppt.pptChadharris42
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworksMukesh Kumar
 
J2 EEE SIDES
J2 EEE  SIDESJ2 EEE  SIDES
J2 EEE SIDESbputhal
 
Instant J Chem - Introduction and latest
Instant J Chem - Introduction and latestInstant J Chem - Introduction and latest
Instant J Chem - Introduction and latestChemAxon
 
Dao pattern
Dao patternDao pattern
Dao patternciriako
 
Oracle Data Integrator 11g Integration and Administration
Oracle Data Integrator 11g  Integration and AdministrationOracle Data Integrator 11g  Integration and Administration
Oracle Data Integrator 11g Integration and AdministrationMd. Noor Alam
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...WebStackAcademy
 
Design patterns fast track
Design patterns fast trackDesign patterns fast track
Design patterns fast trackBinu Bhasuran
 
Whats Next for JCA?
Whats Next for JCA?Whats Next for JCA?
Whats Next for JCA?Fred Rowe
 
TheSpringFramework
TheSpringFrameworkTheSpringFramework
TheSpringFrameworkShankar Nair
 
FIWARE Global Summit - A Multi-database Plugin for the Orion FIWARE Context B...
FIWARE Global Summit - A Multi-database Plugin for the Orion FIWARE Context B...FIWARE Global Summit - A Multi-database Plugin for the Orion FIWARE Context B...
FIWARE Global Summit - A Multi-database Plugin for the Orion FIWARE Context B...FIWARE
 
Session 34 - JDBC Best Practices, Introduction to Design Patterns
Session 34 - JDBC Best Practices, Introduction to Design PatternsSession 34 - JDBC Best Practices, Introduction to Design Patterns
Session 34 - JDBC Best Practices, Introduction to Design PatternsPawanMM
 
OpenProdoc Overview
OpenProdoc OverviewOpenProdoc Overview
OpenProdoc Overviewjhierrot
 
Spring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applicationsSpring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applicationsmichaelaaron25322
 
J2EE PPT --CINTHIYA.M Krishnammal college for women
J2EE PPT --CINTHIYA.M Krishnammal college for womenJ2EE PPT --CINTHIYA.M Krishnammal college for women
J2EE PPT --CINTHIYA.M Krishnammal college for womenlissa cidhi
 
EDB & ELOS Technologies - Break Free from Oracle
EDB & ELOS Technologies - Break Free from OracleEDB & ELOS Technologies - Break Free from Oracle
EDB & ELOS Technologies - Break Free from OracleEDB
 

Similar to Managing Data in Jakarta EE Applications (20)

2008_478_Lyons_ppt.ppt
2008_478_Lyons_ppt.ppt2008_478_Lyons_ppt.ppt
2008_478_Lyons_ppt.ppt
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworks
 
J2 EEE SIDES
J2 EEE  SIDESJ2 EEE  SIDES
J2 EEE SIDES
 
Instant J Chem - Introduction and latest
Instant J Chem - Introduction and latestInstant J Chem - Introduction and latest
Instant J Chem - Introduction and latest
 
Data access
Data accessData access
Data access
 
Dao pattern
Dao patternDao pattern
Dao pattern
 
Oracle Data Integrator 11g Integration and Administration
Oracle Data Integrator 11g  Integration and AdministrationOracle Data Integrator 11g  Integration and Administration
Oracle Data Integrator 11g Integration and Administration
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 
Midao JDBC presentation
Midao JDBC presentationMidao JDBC presentation
Midao JDBC presentation
 
Design patterns fast track
Design patterns fast trackDesign patterns fast track
Design patterns fast track
 
spring
springspring
spring
 
Whats Next for JCA?
Whats Next for JCA?Whats Next for JCA?
Whats Next for JCA?
 
TheSpringFramework
TheSpringFrameworkTheSpringFramework
TheSpringFramework
 
FIWARE Global Summit - A Multi-database Plugin for the Orion FIWARE Context B...
FIWARE Global Summit - A Multi-database Plugin for the Orion FIWARE Context B...FIWARE Global Summit - A Multi-database Plugin for the Orion FIWARE Context B...
FIWARE Global Summit - A Multi-database Plugin for the Orion FIWARE Context B...
 
Session 34 - JDBC Best Practices, Introduction to Design Patterns
Session 34 - JDBC Best Practices, Introduction to Design PatternsSession 34 - JDBC Best Practices, Introduction to Design Patterns
Session 34 - JDBC Best Practices, Introduction to Design Patterns
 
OpenProdoc Overview
OpenProdoc OverviewOpenProdoc Overview
OpenProdoc Overview
 
Spring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applicationsSpring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applications
 
70487.pdf
70487.pdf70487.pdf
70487.pdf
 
J2EE PPT --CINTHIYA.M Krishnammal college for women
J2EE PPT --CINTHIYA.M Krishnammal college for womenJ2EE PPT --CINTHIYA.M Krishnammal college for women
J2EE PPT --CINTHIYA.M Krishnammal college for women
 
EDB & ELOS Technologies - Break Free from Oracle
EDB & ELOS Technologies - Break Free from OracleEDB & ELOS Technologies - Break Free from Oracle
EDB & ELOS Technologies - Break Free from Oracle
 

Recently uploaded

Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 

Recently uploaded (20)

Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 

Managing Data in Jakarta EE Applications

  • 1.
  • 2. Managing Data in Jakarta EE Applications
  • 3. Who am I? Buhake Sindi ● Senior Full Stack Java Architect & Engineer/Developer & Consultant ● Over 17+ years in Enterprise Java development ● Founded Sindi Technologies (Pty) Ltd ● Founded Devoxx4Kids South Africa (NPO) ● Jakarta EE Ambassador ● Blogger (DZone Core Member) ● Runner, Beat Maker, Podcaster?
  • 4. Where can you find me? https://linktr.ee/theEliteGentleman buhake@gmail.com www.sindi.co.za X: @EliteGentleman Also
  • 5. Table of contents Handling data in the early days Isolating data from your application Repository Pattern in current Jakarta EE release Repository in future release of Jakarta EE 01 02 03 04
  • 7. Handling data in the early days… 01
  • 8. Early days… Monolithic architecture Vendor-specific APIs All components (presentation, business & data access) were tightly integrated into a single deployment unit. Early Java EE specifications were not as standardized as today. App servers provided their own specific APIs, making applications tightly coupled to the specific application server.
  • 9. Enterprise Java Beans (EJBs) Early versions of EJBs (particularly EJB 2.x) heavily depended on implementation of EJB specific interfaces. Entity Bean was introduced to represent persistent data maintained in the database. ● Beans were defined to the persistence management (BMP or CMP). Difficult to maintain, less flexible & portable (as it heavily relied on application server implementation of EJBs)
  • 10. Challenges… Limited Separation of concerns Limited Dependency Injection Business logic, presentation and data access were often mixed Tight integration with JNDI. Also heavy reliance of XML deployment descriptors Tight coupling Limited support for POJOs. Limited code reusability. Difficulty in testing & providing mocks.
  • 12. EAA and frameworks Use of Plain-Old-Java-Objects (POJO), Plain-Old-Java-Interfaces (POJI) ● Specification: Java Data Objects (JDO) ● Data Access Objects (DAO) ● Frameworks: iBatis/myBatis, TopLink, jOOQ ● ORM: Hibernate What’s your flavour? Thus, a needed vendor-agnostic standardisation was needed for EAA.
  • 13. Advantages Portability Providing a level of abstraction that is portable across different data stores. Consistent API Standardized API for interacting with DBs can help simplify learning curve for developers & bring uniform coding style. Testability Using POJO, POJI & DI it’s easier to write unit tests for business logic. Separation of concerns Isolation of data access and persistence from the business logic
  • 14. Challenges Performance Overheads Depending on specific implementations and configurations Learning Curve For developers who are new to these concepts. Boilerplate code Implementation of various framework may introduce boilerplate code for CRUD Limited industry adoption Various frameworks took widespread adoptions compared to other frameworks
  • 15. Further Challenges Vendor focused Some queries may result in vendor specific queries. Lack of support for NoSQL DBs Debugging & Profiling Especially with generated SQL queries Tight coupling E.g. change of DB Schema
  • 16. Isolating data from your application 02
  • 17. Purpose To separate the data layer and data access logic from the rest of your application components.
  • 18. Key aspects and principles ● Separation of concerns: Keep data access logic separate from the business logic. ● Testability: Make your data access logic easier to write unit test for your business logic. ● Encapsulation: Hide the details of data storage and retrieval within data access layer. ● Abstraction: Make use of abstract classes and interfaces to define the contract between the data access layer and the rest of the applications. ● Data Access Layer: Encapsulate all interactions with Data Access Logic. ● Interfaces for Data Access: Clean and well-defined contract for data access operations (CRUD). ● Use of Design Pattern: DAO / Repository pattern to structure and isolate data access logic. ● Dependency Injection: Business Logic should depend on Data Access Logic through abstraction. ● ORM: Usage of JPA/Hibernate allows interactions through POJOs, while abstracting database interactions.
  • 19. The Repository pattern Meets all aspects and principles of data isolation: ● Data Access Layer. ● Interfaces for Data Access. ● Use of design pattern (also, caching with strategy pattern?); ● Provides abstraction and loose- coupling between data access and rest of your application.
  • 20. Data Support many data stores Support of DI Relational DBs (JDBC, JPA, Hibernate Session), NoSQL (MongoDB, Redis, Cassandra) Through CDI extensions Query Methods Via @Query or Criteria APIs Repository abstraction Via interfaces: JpaRepository (for JPA), CassandraRepository (Cassandra), etc.
  • 21. Repository Pattern in current Jakarta EE release 03
  • 22. Key aspects Injectable With Jakarta CDI @Inject Testable Either with jUnit, Mockito, Testcontainers, etc. Abstractable Encapsulate Data Access Layer & still integrate with ORM / JPA, JDBC, etc. Repository abstraction Via Repository interface(s)
  • 23. Deltaspike Data Support many data stores Support of DI JPA centric and relational databases. No NoSQL support. Through CDI extensions Query Methods Via @Query module (with JPQL queries) Repository abstraction Via @Repository annotation on repository interface (that extends EntityRepository)
  • 24. Custom approach Best of both Spring Data and Deltaspike Data approach
  • 25. Domain object (I) Entity (I) IdentifiableEntity<ID> (A) JPAEntity<ID> (I) CreatedTimestamp (I) LastModifiedTimestamp (I) SoftDeletedTimestamp
  • 26. Domain Entity Domain objects represent the entities or business objects in the application's domain. The repository is responsible for persisting and retrieving these domain objects. The use of domain objects ensures that the data access layer aligns with the application's business logic.
  • 27.
  • 28. Repository (I) DataRepository<E> (I) CrudRepository<E, ID> (I) SpecificationRepository (I) MicrostreamRepository (I) JPARepository (I) Specification<E> (I) CassandraRepository (A) AbstractJPARepository
  • 29. The repository pattern is the design pattern, used in software development to create an abstraction layer between the application’s business logic and the data access code responsible for interacting with the database or other data sources. Here’s key component we’ve implemented for our Repository Pattern: • Repository interface: At the core of the Repository pattern is the interface that defines a sets of methods for interacting with the data. Each interface abstracts away the data and is defined for the specific domain entity. • Super interface: DataRepository • Sub interface: CrudRepository – Common database operations. Repository key components
  • 30.
  • 31.
  • 32.
  • 33. • Concrete Repository implementation: The repository interface is implemented by a concrete class that provides that actual implementation of that data access logic. This class interacts with the underlying data store to execute the defined operations. Repository key components
  • 34.
  • 35.
  • 36. Making CDI injectable @Repository annotation A CDI Stereotype annotation that makes the class a CDI bean when CDI is available. The repository implementation must be made available via the @jakarta.inject.Inject annotation.
  • 37.
  • 38.
  • 39. 1. Stateless repository: Can inherit state & transactions from business services (EJB 3.x) 2. Reduced boilerplate code: Abstract classes have implemented all common database operations. 3. Entity association: E.g., JPARepository is strongly linked to JPAEntity Other features
  • 40. 1. Repository interface allows us to create mock implementations to be used for testing. 2. Suitable for jUnit, Mockito tests. Testing
  • 42. Jakarta Data Jakarta Data defines core APIs for the Jakarta EE platform allowing applications and other Jakarta EE components to explore the benefits of easy access to data technologies such as relational and non- relational databases, cloud- based data services, and so on.
  • 43. Goals: 1. Increase productivity performing common database operations. 2. Rich Object Mapping integrated. 3. Define Repositories. Still under development: 1. Release will support Jakarta EE 11 2. Specification: https://jakarta.ee/specifications/data/1.0/data- 1.0.0-m1 Jakarta Data 1.0
  • 44. Features: 1. @Repository 2. @Query 3. @Insert, @Update, @Delete 4. @Lifecycle 5. Stateless Repository 6. Built-in interfaces Jakarta Data 1.0
  • 45. Currently: 1. In beta on OpenLiberty Beta (23.0.0.12-beta) 2. Include data-1.0 as feature in server.xml Jakarta Data 1.0
  • 46.
  • 48. Q&A
  • 49. Thank you! Do you have any questions? buhake@gmail.com www.sindi.co.za