As I was reading a lot lately regarding the Ports and Adapters architecture, I stumbled upon this piece of code as a part of an application that was build following the above mentioned architecture :
package com.example.user.management;
import lombok.*;
import javax.persistence.*;
import java.io.Serializable;
@Table(name = "user")
@AllArgsConstructor
@Data
@NoArgsConstructor
@javax.persistence.Entity
@Setter
@Getter
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class User implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private Long id;
@Column(name = "username")
private String username;
@Column(name = "password")
private String password;
@Column(name = "role")
private String role;
public User(String username, String password, String role) {
this.username = username;
this.password = password;
this.role = role;
}
}
As the main intent of the Ports and Adapters architecture is to separate and isolate the domain layer from any technical details and implementations, and having in mind that this User entity is in fact, the domain layer, doesn't it contain dependency to the java persistence library? As I understand it, the domain layer is responsible only for implementing the use-cases. I am really confused as per what should actually be the Domain Layer in this type of architecture.
Aucun commentaire:
Enregistrer un commentaire