Moving Jakarta Forward: Jakarta NoSQL Approved as an EE4J Project

このエントリは以下のエントリをベースにしています。
This entry is based on the following one written by Otavio Santana (Software Engineer, SouJava/Platform.sh).
https://dzone.com/articles/moving-jakarta-forward-jakarta-nosql-has-approved

Jakarta NoSQLがこれまでの1年のコミュニティによる作業の結果、EE4Jとして承認されました。

Jakarta NoSQL
https://projects.eclipse.org/projects/ee4j.nosql

この仕様に関する主な質問への説明を書いたエントリがいくつか出ています。

The first step in Jakarta NoSQLの技術的な最初の一歩はAPIの作成です。APIにはモジュール性があり、それはEclipse JNoSQLに由来します。したがって、Jakarta NoSQLがAPIとTCKであり、EclipseJNoSQLがそれに対する参照実装です。

Eclipse JNoSQL
http://www.jnosql.org/

最初のスコープのプロジェクトが存在し、Jakarta NoSQLとしてEclipse Foundationに移行するための法的プロセスがあります。基本的にEclipse JNoSQLからの移行に関するものです。新しいパッケージ名は “jakarta.nosql”です。以下のコードは、将来のAPIの使い方の例です。

Eclipse JNoSQL
http://www.jnosql.org/
https://github.com/eclipse-ee4j/nosql

import jakarta.nosql.document.DocumentCollectionManager;
import jakarta.nosql.document.DocumentCollectionManagerFactory;
import jakarta.nosql.document.DocumentConfiguration;
import jakarta.nosql.document.DocumentDeleteQuery;
import jakarta.nosql.document.DocumentEntity;
import jakarta.nosql.document.DocumentQuery;
import java.util.Arrays;
import java.util.List;

public class App {

    public static void main(String[] args) {
        //it loads from Service loader
        DocumentConfiguration configuration = DocumentConfiguration.getConfiguration();
        try (DocumentCollectionManagerFactory managerFactory = configuration.get()) {
            final DocumentCollectionManager manager = managerFactory.get("database");
            DocumentEntity entity = DocumentEntity.of("God");
            entity.add("name", "Diana");
            entity.add("age", 10);
            entity.add("versions", Arrays.asList("0.0.1", "0.0.2", "0.0.3"));
            manager.insert(entity);
            List<DocumentEntity> entities = DocumentQuery.select().from("God")
                    .where("name").eq("Diana").execute(manager);
            DocumentDeleteQuery.delete().from("God")
                    .where("age").gte(10).execute(manager);
        }
    }
}

Jakarta NoSQLはEclipse JNoSQLと同じアプローチを使う予定です。言い換えると、NoSQLタイプ(Key-Value、カラム、ドキュメント、グラフ)ごとに1つのAPIがあります。マッピングでは、Entity、Column、IdなどのMappingアノテーションを含む、すべてのNoSQLデータベースに共有されるクラスを持つ共通APIを伴う同じパスを使用します。

import jakarta.nosql.mapping.Column;
import jakarta.nosql.mapping.Entity;
import jakarta.nosql.mapping.Id;
import java.util.List;

@Entity
public class Person {
    @Id
    private Long id;
    @Column
    private String name;
    @Column
    private List<String> phones;
    //getter and setter
}

import jakarta.nosql.document.DocumentQuery;
import jakarta.nosql.mapping.document.DocumentTemplate;
import javax.enterprise.inject.se.SeContainer;
import javax.enterprise.inject.se.SeContainerInitializer;
import java.util.Arrays;
import java.util.Optional;
import java.util.concurrent.ThreadLocalRandom;
import static jakarta.nosql.document.DocumentQuery.select;

public class App2 {

    public static void main(String[] args) {
        ThreadLocalRandom random = ThreadLocalRandom.current();
        Long id = random.nextLong();
        try (SeContainer container = SeContainerInitializer.newInstance().initialize()) {
            Person person = new Person();
            person.setPhones(Arrays.asList("234", "432"));
            person.setName("Name");
            person.setId(id);
            DocumentTemplate template = container.select(DocumentTemplate.class).get();
            Person saved = template.insert(person);
            System.out.println("Person saved" + saved);
            DocumentQuery query = select().from("Person")
                    .where("_id").eq(id).build();
            Optional<Person> personOptional = template.singleResult(query);
            System.out.println("Entity found: " + personOptional);
        }
    }
}

Jakarta EEには明るい未来があります。オープンソースであり、重要な統合の機能が含まれており、そして最も重要なのはコミュニティです。結局のところ、透明性を高めることがJakartaの最も強力な側面です。つまりテクノロジ自体ではなく、コミュニティの中心の透明性です。したがって、成功は各開発者の手に委ねられています。 この最初のJakarta EEの仕様で両方を提供したいと思っています。

コメントを残す

以下に詳細を記入するか、アイコンをクリックしてログインしてください。

WordPress.com ロゴ

WordPress.com アカウントを使ってコメントしています。 ログアウト /  変更 )

Facebook の写真

Facebook アカウントを使ってコメントしています。 ログアウト /  変更 )

%s と連携中