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

Getting org.springframework.data.mapping.model.MappingInstantiationException after a restart of the application
Customizing Param Binding for QueryDSL Support
Bean name is ambiguous matches same bean twice
Error upgrading to Mongo java driver 3.2.2
Spring Data Redis: Setting a Password
Spring Data QueryDSL predicate two table join specification
specification groupBy in query and pagination
Spring Repository: get number of deleted rows
SpringData PageImpl totalElements is wrong
Spring Data MongoDB. Custom #Query with current date
Spring Data - Mongo DB - search
How to query using fields of subclasses for Spring data repository
Spring Data Elasticsearch Parent/Child Document Repositories / Test execution error
DynamoDB FilterExpression find all foreign keys that contain a set of attributes
Toplink release UnitOfWork Resources
what is the difference between indexOps and #Indexed

Categories

HOME
qt
entity-framework
apache-nifi
yii
qc
softlayer
antd
gallery
qooxdoo
tibco
azure-data-lake
minecraft
heuristics
xamarin-zebble
match
documentum
xbap
mailgun
susy-sass
gmp
spring-shell
azure-machine-learning
spring-ldap
workday
bosun
uislider
spreadsheetgear
points
laravel-4.2
sparkle
publishing
argv
cloudera-manager
serversocket
cloveretl
image-optimization
eclipse-gmf
grunt-contrib-watch
resampling
data-uri
pyttsx
elasticsearch-aggregation
django-static-precompiler
password-hash
subforms
aurelia-fetch-client
popen
patternlab.io
stateless-session-bean
word-2016
rustdoc
sidewaffle
pbx
google-identity-toolkit
between
jtag
frame-grab
jeditable
textblock
gravatar
flush
servicestack-bsd
bayesglm
arbre
fantom
erlog
gflags
ssmtp
sql-processor
dos2unix
nesper
squeezebox
siena
reference-counting
zend-search-lucene
cloo
pbkdf2
rautomation
jquery-lazyload
axacropdf
dibs
tfs-sdk
linkbutton
audiotoolbox
kaazing
zotonic
firebird1.5
n-queens
snackjs
directshow.net
simile
webresponse
pyjamas
jdownloader
odac
self-tracking-entities
.net-services
getimagesize
zend-test
eventaggregator
dm
firephp
.net-client-profile
version-control-migration
server-load
activex-exe
isapi-redirect
jvm-bytecode

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App