ddd-repositories

Where to define the interfaces for a repository in an layered architecture?

假如想象 提交于 2019-12-04 02:13:39
Background I'm trying to create a simple application to really understand the whole stack of DDD+TDD+etc. My goal is to dynamically inject the DAL repository classes at runtime. This keeps my Domain and Application Services layers testable. I plan on using "poor man's DI" to accomplish this for now ... so I would do this in a simple Console application near startup: // Poor man's DI, injecting DAL repository classes at runtime var productRepository = new SimpleOrder.Repository.ProductRespository(); var customerRepository = new SimpleOrder.Repository.CustomerRepository(); var orderRepository =

Setting up a repository pattern in MVC

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 01:56:07
I'm trying to figure out how the Repository pattern works and how it can be implemented in a custom MVC pattern. As far as i understand it, the Repository is a layer which simply returns data from an entity class or saves the entity class to a persistent layer. Now i currently see it like this: A request comes in into my controller to create a user. Just a username and password. My controller will do something like this: function CreateAction ( ) { $userRepo = new userRepository ( ); $user = new userEntity ( ); $user->setUsername('user'); $user->setPassword('123456'); $userRepo->create($user);

Approach for a (generic) DDD Repository with JPA/Spring: does it look wrong?

荒凉一梦 提交于 2019-12-03 17:19:34
I'm pretty new to DDD and JPA. I'm working on a generic Repository with JPA and Spring. I really like the approaches exposed in the articles DDD: The Generic Repository and JPA implementation patterns: Data Access Objects . My aim is to build the perfect Repository in Domain-Driven Design with JPA and Spring. I use an internal generic Repository to respect the domain’s contract with the data store , following the first article concepts. public interface IInternalGenericRepository<K, E> { List<E> read(String query, Object[] params); void persist(E entity); void remove(E entity); } public class

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

拟墨画扇 提交于 2019-12-03 05:19:55
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

Question about Repositories and their Save methods for domain objects

孤街醉人 提交于 2019-12-03 04:35:31
问题 I have a somewhat ridiculous question regarding DDD, Repository Patterns and ORM. In this example, I have 3 classes: Address , Company and Person . A Person is a member of a Company and has an Address. A Company also has an Address. These classes reflect a database model. I removed any dependencies of my Models, so they are not tied to a particular ORM library such as NHibernate or LinqToSql. These dependencies are dealt with inside the Repositories. Inside one of Repositories there is a

Domain driven design repository implementation in infrastructure layer

岁酱吖の 提交于 2019-12-03 03:06:22
I got a question on dependencies of DDD layered architecture. If the Repository implementation is in the infrastructure layer, that means that infrastructure layer has a dependency on domain layer because Entities will be referenced in the Repository implementation. On the other side, the Domain layer can have references to the infrastructure layer if infrastructure services are used in the domain. Wouldn't this create a cyclic reference? GraemeMiller Look at the onion architecture it shows a good setup for a DDD solution. Basically all domain model and interfaces for domain services are

Question about Repositories and their Save methods for domain objects

╄→尐↘猪︶ㄣ 提交于 2019-12-02 17:45:55
I have a somewhat ridiculous question regarding DDD, Repository Patterns and ORM. In this example, I have 3 classes: Address , Company and Person . A Person is a member of a Company and has an Address. A Company also has an Address. These classes reflect a database model. I removed any dependencies of my Models, so they are not tied to a particular ORM library such as NHibernate or LinqToSql. These dependencies are dealt with inside the Repositories. Inside one of Repositories there is a SavePerson(Person person) method which inserts/updates a Person depending on whether it already exists in

How to alter the design so that entities don't use injections?

我的梦境 提交于 2019-12-01 16:58:56
I've read and came to realize myself that entities (data objects - for JPA or serialization) with injections in them is a bad idea. Here is my current design (all appropriate fields have getters and setter, and serialVersionUID which I drop for brevity). This is the parent object which is the head of the entity composition graph. This is the object I serialize. public class State implements Serializable { List<AbstractCar> cars = new ArrayList<>(); List<AbstractPlane> planes = new ArrayList<>(); // other objects similar to AbstractPlane as shown below } AbstractPlane and its subclasses are

How to alter the design so that entities don't use injections?

限于喜欢 提交于 2019-12-01 15:01:17
问题 I've read and came to realize myself that entities (data objects - for JPA or serialization) with injections in them is a bad idea. Here is my current design (all appropriate fields have getters and setter, and serialVersionUID which I drop for brevity). This is the parent object which is the head of the entity composition graph. This is the object I serialize. public class State implements Serializable { List<AbstractCar> cars = new ArrayList<>(); List<AbstractPlane> planes = new ArrayList<>

How linq 2 sql is translated to TSQL

[亡魂溺海] 提交于 2019-12-01 13:59:31
It seems Linq2sql doesn't know how to construct the TSQL while you transform linq2sql object into domain object with constructors. Such as: from c in db.Companies select new Company (c.ID, c.Name, c.Location).Where(x => x.Name =="Roy"); But when using settable attributes, it will be OK. from c in db.Companies select new Company { ID = c.ID, Name = c.Name, Location = c.Location }.Where(x => x.Name =="Roy"); I don't want to allow those attributes to be settable. How can I achieve this? And can anybody provide food for thought on how linq 2 sql is translated into TSQL? Thanks in advance! It's