Jakarta EE 具体模块的拆解 —— Jakarta NoSQL (对于数据的标注,以及 实例的注解)

Jakarta NoSQL

https://jakarta.ee/specifications/nosql/

Jakarta NoSQL defines a standard for creating applications with NoSQL databases.

Jakarta NoSQL is a standalone Specification with a future goal of becoming part of the Jakarta EE 10 platform.

雅加达NoSQL为使用NoSQL数据库创建应用程序定义了一套标准。

雅加达NoSQL是一项独立规范,其未来目标是将成为雅加达EE 10平台的一部分。

Jakarta NoSQL is a Java API standard that streamlines the integration of Java applications with NoSQL databases. It defines a set of APIs and provides a standard implementation for most NoSQL databases. The goal is to create the specification in Jakarta EE to help Jakarta EE developers create enterprise-grade applications using Java® and NoSQL technologies. It helps them create scalable applications while maintaining low coupling with the underlying NoSQL technology.

雅加达NoSQL是一项Java API标准,旨在简化Java应用程序与NoSQL数据库的集成。它定义了一组API,并为大多数NoSQL数据库提供标准实现。其目标是在雅加达EE中创建规范,帮助雅加达EE开发者使用Java®和NoSQL技术构建企业级应用。该标准使开发者能创建可扩展的应用程序,同时保持与底层NoSQL技术的低耦合性。

https://jakarta.ee/specifications/nosql/1.0/

Goals

  • Increase productivity performing common NoSQL operations.
  • Rich Object Mapping integrated.
  • Java-based Query and Fluent-API.
  • It is designed to work with various NoSQL databases and can quickly adapt to support new types and behaviors through extensions.
  • Annotation-oriented using Jakarta Persistence-like naming when it makes sense.
@Inject
Template template;
...

Car ferrari = Car.id(1L)
        .name("Ferrari")
        .type(CarType.SPORT);

template.insert(ferrari);
Optional<Car> car = template.find(Car.class, 1L);
template.delete(Car.class, 1L);
@Entity
public class Car {

    @Id
    private Long id;
    @Column
    private String name;
    @Column
    private CarType type;
 //...
}

The annotations from the Mapping API will look familiar to Jakarta Persistence developers:

Annotation Description
@Entity Specifies that the class is an entity. This annotation is applied to the entity class.
@Id Specifies the primary key of an entity.
@Column Specifies the mapped column for a persistent property or field.
@MappedSuperclass Specifies a class whose mapping information is applied to entities that inherit from it.
@Embeddable Declares a class whose instances are stored as an intrinsic part of an owning entity, sharing the identity of the entity.
@Inheritance Specifies the inheritance mapping strategy for the entity class hierarchy.
@DiscriminatorColumn Specifies the discriminator column for the mapping strategy.
@DiscriminatorValue Specifies the value of the discriminator column for the annotated entity type.
@Convert Specifies how the values of a field or property are converted to a basic type or a type that can be persisted by a persistence provider.

These annotations provide a powerful toolkit for defining and mapping entities in NoSQL databases, analogous to their counterparts in Jakarta Persistence.

After mapping an entity, you can explore the advantage of using a Template interface, which can increase productivity on NoSQL operations.

@Inject
Template template;
...

Car ferrari = Car.id(1L)
        .name("Ferrari")
        .type(CarType.SPORT);

template.insert(ferrari);
Optional<Car> car = template.find(Car.class, 1L);
template.delete(Car.class, 1L);

var cars = template.select(Car.class).where("type").eq(CarType.SPORT).result();

Details

https://projects.eclipse.org/projects/ee4j.nosql/releases/1.0

https://jakarta.ee/specifications/nosql/1.0/apidocs

Module jakarta.nosql.core


module jakarta.nosql.core

Jakarta NoSQL

Jakarta NoSQL is designed specifically for Java developers who need to build scalable, database-agnostic applications using NoSQL technologies. With Jakarta NoSQL, developers can seamlessly map Java objects to NoSQL databases using familiar paradigms, enabling them to focus on business logic without worrying about database-specific implementation details.

雅加达NoSQL专为需要利用NoSQL技术构建可扩展、与数据库无关的应用程序的Java开发者设计。通过雅加达NoSQL,开发者能够使用熟悉的范式将Java对象无缝映射到NoSQL数据库,从而专注于业务逻辑,而无需担心特定数据库的实现细节。

Overview

Modern applications often require highly scalable and flexible storage solutions. NoSQL databases address these needs with their diverse data models (e.g., document, key-value, column-family, and graph). However, interacting with such databases in a type-safe, database-agnostic way has historically been challenging. Jakarta NoSQL solves this problem by offering:

现代应用通常需要高度可扩展且灵活的存储解决方案。NoSQL数据库通过其多样化的数据模型(如文档、键值、列族和图)满足这些需求。然而,以类型安全、与数据库无关的方式与这类数据库交互历来存在挑战。雅加达NoSQL通过提供以下功能解决了这个问题:

  • A standard API for NoSQL database interactions.
  • Comprehensive support for mapping Java objects to NoSQL data models.
  • Seamless integration with Java frameworks and runtime environments.

Annotations

Jakarta NoSQL introduces several annotations to make it easier for Java developers to define mappings between Java objects and NoSQL databases. These include:

  • Entity: Marks a class as a NoSQL entity, representing a top-level record i
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值