jakarta.data.metamodel.package-info Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2023,2024 Contributors to the Eclipse Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* A static metamodel for entities that are used in Jakarta Data repositories.
*
* The {@link jakarta.data.metamodel.StaticMetamodel} allows for type-safe operations that avoid the
* need to hard-code entity attribute names as Strings. For example,
*
*
* @Entity
* public class Product {
* @Id
* public long id;
*
* public String name;
*
* public float price;
* }
*
* @StaticMetamodel(Product.class)
* public interface _Product {
* String ID = "id";
* String NAME = "name";
* String PRICE = "price";
*
* SortableAttribute<Product> id = new SortableAttributeRecord<>(ID);
* TextAttribute<Product> name = new TextAttributeRecord<>(NAME);
* SortableAttribute<Product> price = new SortableAttributeRecord<>(PRICE);
* }
*
* ...
*
* @Repository
* Products products;
*
* ...
*
* Order<Product> order =
* Order.by(_Product.price.desc(),
* _Product.name.asc(),
* _Product.id.asc());
*
* page1 = products.findByNameLike(namePattern, pageRequest);
*
*
* The module Javadoc provides an {@link jakarta.data/ overview} of Jakarta Data.
*/
package jakarta.data.metamodel;