spring-data


Is there a mismatch between Domain-Driven Design repositories and Spring Data ones?


DDD specifies repository per aggregate, but when embracing Spring Data JPA, we can leverage the benefits only when we declare interface per entity. How this impedance mismatch can be resolved?
I'm hoping to try out repository interfaces encapsulated within the aggregate repository, is that a OK solution or anything better available?
To given an example: Customer is the aggregate root and entities are like Demographics, Identification, AssetSummary etc. where each entity can benefit from having their own repository interfaces. What is the best way without violating DDD much?
…, but when embracing Spring Data JPA, we can leverage the benefits only when we declare interface per entity…
That's wrong and I would like to learn where you get this impression from (feel free to comment). Spring Data repositories are expecting the exactly same approach to your domain model design: you identify aggregates in your domain model and only create repository interfaces for exactly those.
I'd argue that all you need to do is applying the DDD concept to your domain model. Simply don't declare repository interfaces for entities that are not an aggregate root. In fact, if you declared those, you basically break the concept of an aggregate, as the actual root cannot control business constraints anymore as the other entities can be manipulated through the repository interface defined for them, i.e. without using the aggregate root.
Find an example of this applied correctly in this Spring Data example. In it, Order is an aggregate root, LineItem is just an ordinary entity. The same applies to Customer (root) and Address (ordinary entity). Repository interfaces only exist for the aggregate roots.
In fact, that particular relationship is the fundamental principle that makes modules like Spring Data REST working in the first place. It only exposes HTTP resources for aggregate roots, embeds ordinary entities within the representations created and creates links to other aggregates.

Related Links

How to create specification using JpaSpecificationExecutor by combining tables?
Is it possible to use spring-data-rest-webmvc without an actual Repository?
Couchbase - Eviction
Variables with underscores create compile error within derived query methods (spring-data)
Weblogic 12 + Spring Data JPA + CDI issues
Javascript CRUD Admin for Spring-Data HATEOAS backend
Spring HATEOAS Link with Matrix Variable Not Working
Spring bean name clash Hibernate/Proguard?
How to specify Schema name while using #NamedStoredProcedureQuery
Spring Data Joda Time Duration Type store in mongoDB
Spring JpaRepository how to query a #ManyToMany entity
What is the difference between findAllBy and readAllBy?
How to make index name to resolve dynamically
Querying Tables with Composite Primary Keys using Spring-data-cassandra
#QuerydslPredicate in spring test fails in standaloneSetup
How to create a spring data query that returns only those entities that have a UserRole which contains the passed user object?

Categories

HOME
rust
generics
shinyapps
bing-search
google-webmaster-tools
header
repair
msmq
jquery-select2-4
spring-jpa
trace32
asp.net-core-1.0
twisted
pywinauto
jqxgrid
gmp
android-custom-view
node-webkit
social-tables
android-permissions
uislider
pymongo
amazon-sns
ratio
mod-wsgi
running-object-table
annotation-processing
macromedia
adapter
sales
windows2012
mongodb-3.4
xmlunit
orchardcms-1.8
netstat
mv
elastica
assemblies
flowchart
slideshow
jacoco-maven-plugin
klee
get-event-store
axis
.net-micro-framework
renderman
node-apn
maven-jaxb2-plugin
mobile-angular-ui
sesame
openerp-6
bilinear-interpolation
visual-studio-monaco
zynq
mathml
groovyfx
node-glob
adjacency-list
jemdoc
jsr363
ui4j
lovefield
knife
cache-manifest
angular-amd
physicsjs
tree-structure
debug-symbols
famo.us
device-admin
smacss
adwords-apiv201402
webautomation
boolean-algebra
spring-social-linkedin
quickgraph
apportable
jquery-lazyload
itunes-sdk
red-system
towers-of-hanoi
spark-view-engine
border-box
image-formats
platform-independent
flymake
mvcrecaptcha
asio
will-paginate
django-pagination
hungarian-notation
odac
browser-based
rational-unified-process
3270
processors
comment-conventions
regioninfo
community-server

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App