Switch to jMolecules integrations 0.4.

To allow records to be used as Identifier implementations (xmolecules/jmolecules-integrations#43). Updated MongoDB and JDBC samples accordingly.
This commit is contained in:
Oliver Drotbohm
2021-04-30 00:42:42 +02:00
committed by Mark Paluch
parent 2de6e0383c
commit 3e71ec637c
6 changed files with 10 additions and 34 deletions

View File

@@ -15,7 +15,7 @@
<properties>
<spring-data-bom.version>2021.0.0-SNAPSHOT</spring-data-bom.version>
<jmolecules.version>1.2.0</jmolecules.version>
<jmolecules-integration.version>0.2.0</jmolecules-integration.version>
<jmolecules-integration.version>0.4.0-SNAPSHOT</jmolecules-integration.version>
</properties>
<dependencies>

View File

@@ -21,7 +21,6 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.Value;
import java.util.ArrayList;
import java.util.List;
@@ -48,7 +47,7 @@ public class Customer implements AggregateRoot<Customer, CustomerId> {
Assert.notNull(address, "Address must not be null!");
this.id = new CustomerId(UUID.randomUUID().toString());
this.id = new CustomerId(UUID.randomUUID());
this.firstname = firstname;
this.lastname = lastname;
@@ -57,6 +56,5 @@ public class Customer implements AggregateRoot<Customer, CustomerId> {
this.addresses.add(address);
}
public record CustomerId(String id) implements Identifier {
}
public record CustomerId(UUID id) implements Identifier {}
}

View File

@@ -25,7 +25,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import lombok.Value;
import org.jmolecules.ddd.types.AggregateRoot;
import org.jmolecules.ddd.types.Association;
import org.jmolecules.ddd.types.Identifier;
@@ -47,7 +46,7 @@ public class Order implements AggregateRoot<Order, Order.OrderId> {
public Order(Customer customer) {
this.id = OrderId.of(UUID.randomUUID());
this.id = new OrderId(UUID.randomUUID());
this.customer = Association.forAggregate(customer);
this.lineItems = new ArrayList<>();
}
@@ -61,13 +60,5 @@ public class Order implements AggregateRoot<Order, Order.OrderId> {
return this;
}
@Value(staticConstructor = "of")
public static class OrderId implements Identifier {
UUID orderId;
public static OrderId create() {
return OrderId.of(UUID.randomUUID());
}
}
public record OrderId(UUID id) implements Identifier {}
}

View File

@@ -15,7 +15,7 @@
<properties>
<spring-data-bom.version>2021.0.0-SNAPSHOT</spring-data-bom.version>
<jmolecules.version>1.2.0</jmolecules.version>
<jmolecules-integration.version>0.2.0</jmolecules-integration.version>
<jmolecules-integration.version>0.4.0-SNAPSHOT</jmolecules-integration.version>
</properties>
<dependencies>

View File

@@ -20,7 +20,6 @@ import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;
import lombok.Value;
import java.util.ArrayList;
import java.util.List;
@@ -47,7 +46,7 @@ public class Customer implements AggregateRoot<Customer, CustomerId> {
Assert.notNull(address, "Address must not be null!");
this.id = CustomerId.of(UUID.randomUUID());
this.id = new CustomerId(UUID.randomUUID());
this.firstname = firstname;
this.lastname = lastname;
@@ -56,8 +55,5 @@ public class Customer implements AggregateRoot<Customer, CustomerId> {
this.addresses.add(address);
}
@Value(staticConstructor = "of")
public static class CustomerId implements Identifier {
private final UUID id;
}
public record CustomerId(UUID id) implements Identifier {}
}

View File

@@ -20,7 +20,6 @@ import example.springdata.mongodb.customer.Customer.CustomerId;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import lombok.Value;
import java.util.ArrayList;
import java.util.List;
@@ -44,7 +43,7 @@ public class Order implements AggregateRoot<Order, Order.OrderId> {
public Order(Customer customer) {
this.id = OrderId.of(UUID.randomUUID());
this.id = new OrderId(UUID.randomUUID());
this.customer = Association.forAggregate(customer);
this.lineItems = new ArrayList<>();
}
@@ -58,13 +57,5 @@ public class Order implements AggregateRoot<Order, Order.OrderId> {
return this;
}
@Value(staticConstructor = "of")
public static class OrderId implements Identifier {
UUID orderId;
public static OrderId create() {
return OrderId.of(UUID.randomUUID());
}
}
public static record OrderId(UUID id) implements Identifier {}
}