Skip to content

taymyr/play-repository-java

Repository files navigation

Gitter Gitter_RU Build Status Javadocs Javadocs codecov Maven

DDD Repository pattern for Lagom/Play

API of library contains only one interface Repository for DDD aggregate, inspired the book Implementing Domain-Driven Design by Vaughn Vernon.

Example

JPA

Create the interface of repository for aggregate

public interface AggregateRepository extends Repository<Aggregate, UUID> { }

and implement it

public class AggregateRepositoryImpl extends JPARepository<Aggregate, UUID> implements AggregateRepository {

    @Inject
    public AggregateRepositoryImpl(@Nonnull JPAApi jpaApi, @Nonnull DatabaseExecutionContext executionContext) {
        super(jpaApi, executionContext, Aggregate.class);
    }

    @Override
    public UUID nextIdentity() {
        return UUID.randomUUID();
    }
}

Contributors

Other persistence implementations (for MongoDB/Cassandra/Redis) are welcome.

License

Copyright © Digital Economy League (https://www.digitalleague.ru/).

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.