Hey David,
The first one is the closest.
But instead of only annotation, it has an abstraction such as an interface.
In a simple sample where we have a Server entity, the Jakarta Data will provide a couple of standard annotations to any source system such as Jakarta Persistence or Jakarta NoSQL.
Besides an interface to abstract any data source:
@Entity
public class Server {
@Id
private Long id;
private String name;
private String version;
}
public interface ServerRepository extends Repository<Server, Long> {
List<Server> findByVersion(String version);
}
After it, these abstractions will be injectable into any source implementation.
@ApplicationScoped
public class ServerService {
@Inject
private ServerRepository repository;
public void logServers(String version) {
List<Server> servers = repository.findByVersion(version);
}
}
In the first version, the goal is to push approaches that are data agonists, such as DDD.
Then we can go deeper on it, such as Domain Event, Aggregator Root, CQRS, Event Sourcing, etc.