DanSilva41/eclipse-jnosql-mapping-extension
This project contains all specialization to Eclipse JNoSQL Artemis. The specific behavior in a NoSQL database matters, that's why there are Eclipse JNoSQL Artemis specializations.
= Mapping Extension API
:toc: auto
The Eclipse JNoSQL Mapping Extension API is a collection of implementations/specializations from the https://jakarta.ee/specifications/nosql/[Jakarta NoSQL] specification that defines specific behavior in various NoSQL databases.
== ArangoDB
image::https://jnosql.github.io/img/logos/ArangoDB.png[Arangodb Project,align="center"width=25%, height=25%]
The ArangoDB extension provides an implementation to define specific behavior that is beyond the scope of the API such as the https://www.arangodb.com/docs/stable/aql/[ArangoDB Query Language] (AQL).
=== How To Install
You can use either the Maven or Gradle dependencies:
[source,xml]
org.eclipse.jnosql.mapping aragangodb-extension 1.0.0-b4 ----=== Provide ArangoDB Manager to the CDI Container
[source,java]
public class ArangoDBProducer {
@Produces
public ArangoDBDocumentCollectionManager getManager() {
ArangoDBDocumentCollectionManager manager = ...;
return manager;
}
}
=== Repository
The ArangoDBRepository interface is an extension of the Repository interface that allows execution of AQL via the @AQL annotation.
[source,java]
interface PersonRepository extends ArangoDBRepository<Person, String> {
@AQL("FOR p IN Person RETURN p")
List<Person> findAll();
@AQL("FOR p IN Person FILTER p.name = @name RETURN p")
List<Person> findByName(@Param("name") String name);
}
=== Template
The ArangoDBTemplate interface is a specialization of the DocumentTemplate interface that allows using both synchronous and asynchronous AQL.
[source,java]
@Inject
private ArangoDBTemplate template;
...
List people = template.aql("FOR p IN Person FILTER p.name = @name RETURN p", params);
== Cassandra
image::https://jnosql.github.io/img/logos/cassandra.png[Apache Cassandra,align="center"width=25%, height=25%]
The Cassandra extension provides an implementation to define specific behavior that is beyond the scope of the API such as the https://cassandra.apache.org/doc/latest/cassandra/cql/[Cassandra Query Language] (CQL) and Consistency Level.
=== How To Install
You can use either the Maven or Gradle dependencies:
[source,xml]
org.eclipse.jnosql.mapping cassandra-extension 1.0.0-b4 ----=== Provide Cassandra Manager to the CDI Container
[source,java]
public class CassandraProducer {
@Produces
public CassandraColumnFamilyManager getManager() {
CassandraColumnFamilyManager manager = ...;
return manager;
}
}
=== Repository
The CassandraRepository interface is an extension of the Repository interface that allows execution of CQL and Consistency Level via the @CQL annotation.
[source,java]
interface PersonRepository extends CassandraRepository<Person, String> {
@CQL("select * from Person")
List<Person> findAll();
@CQL("select * from Person where name = ?")
List<Person> findByName(String name);
@CQL("select * from Person where age = :age")
List<Person> findByAge(@Param("age") Integer age);
}
=== @UDT
The @UDT annotation is a mapping annotation that allows defining a field to be stored as a user-defined type in Cassandra.
[source,java]
@entity
public class Person {
@Id("name")
private String name;
@Column
private Integer age;
@UDT("address")
@Column
private Address home;
}
=== Converts
- TimestampConverter: That converts to/from java.util.Date
- LocalDateConverter: That converts to/from com.datastax.driver.core.LocalDate
[source,java]
@Column
@Convert(value = TimestampConverter.class)
private LocalDateTime localDateTime;
@Column
@Convert(value = LocalDateConverter.class)
private Calendar calendar;
=== Template
The CassandraTemplate interface is a specialization of ColumnTemplate interface that allows using CQL.
[source,java]
@Inject
CassandraTemplate template;
...
template.save(person, ConsistencyLevel.ONE);
== Couchbase
image::https://jnosql.github.io/img/logos/couchbase.svg[Couchbase Project,align="center"width=25%, height=25%]
The Couchbase extension provides an implementation to define specific behavior that is beyond the scope of the API such as https://www.couchbase.com/products/n1ql[N1QL] (pronounced "nickel").
=== How To Install
You can use either the Maven or Gradle dependencies:
[source,xml]
org.eclipse.jnosql.mapping couchbase-extension 1.0.0-b4 ----=== Provide Couchbase Manager to the CDI Container
[source,java]
public class CouchbaseProducer {
@Produces
public CouchbaseDocumentCollectionManager getManager() {
CouchbaseDocumentCollectionManager manager = // instance;
return manager;
}
}
=== Repository
The CouchbaseRepository interface is an extension of the Repository interface that allows execution of N1QL via the @N1QL annotation.
[source,java]
interface PersonRepository extends CouchbaseRepository<Person, String> {
@N1QL("select * from Person")
List findAll();
@N1QL("select * from Person where name = $name")
List findByName(@param("name") String name);
}
=== Template
The CouchbaseTemplate interface is a specialization of the DocumentTemplate interface that allows using N1QL on both synchronous and asynchronous.
[source,java]
List people = template.n1qlQuery("select * from Person where name = $name", params);
== Elasticsearch
image::https://jnosql.github.io/img/logos/elastic.svg[Elasticsearch Project,align="center"width=25%, height=25%]
The Elasticsearch extension provides an implementation to define specific behavior that is beyond the scope of the API such as a search engine.
=== How To Install
You can use either the Maven or Gradle dependencies:
[source,xml]
org.eclipse.jnosql.mapping elasticsearch-extension 1.0.0-b4 ----=== Provide Elasticsearch Manager to the CDI Container
[source,java]
public class ElasticsearchProducer {
@Produces
public ElasticsearchDocumentCollectionManager getManager() {
ElasticsearchDocumentCollectionManager manager = // instance
return manager;
}
}
=== Template
The ElasticsearchTemplate interface is a specialization of the DocumentTemplate interface that allows using a search engine on both synchronous and asynchronous.
[source,java]
@Inject
ElasticsearchTemplate template;
...
QueryBuilder queryBuilder = boolQuery().filter(termQuery("name", "Ada"));
List people = template.search(queryBuilder, "Person");
== Hazelcast
image::https://jnosql.github.io/img/logos/hazelcast.svg[Hazelcast Project,align="center" width=25%, height=25%]
The Hazelcast extension provides an implementation to define specific behavior that is beyond the scope of the API such as Hazelcast Query.
=== How To Install
You can use either the Maven or Gradle dependencies:
[source,xml]
org.eclipse.jnosql.mapping hazelcast-extension 1.0.0-b4 ----=== Provide Hazelcast Manager to the CDI Container
[source,java]
public class HazelcastProducer {
@Produces
public HazelcastBucketManager getManager() {
HazelcastBucketManager manager = // instance
return manager;
}
}
=== Repository
[source,java]
interface PersonRepository extends HazelcastRepository<Person, String> {
@Query("active")
List<Person> findActive();
@Query("name = :name AND age = :age")
Set<Person> findByAgeAndInteger(@Param("name") String name, @Param("age") Integer age);
}
=== Template
The HazelcastTemplate interface is a specialization of the KeyValueTemplate interface that allows execution of a Hazelcast query.
[source,java]
Collection people = template.query("active");
Collection people2 = template.query("age = :age", singletonMap("age", 10));
Collection people3 = template.query(Predicates.equal("name", "Poliana"));
== MongoDB
image::https://jnosql.github.io/img/logos/mongodb.png[Cassandra Project,align="center" width=25%, height=25%]
The MongoDB extension provides an implementation to define specific behavior that is beyond the scope of the API such as the Cassandra Query Language, consistency level.
=== How To Install
You can use either the Maven or Gradle dependencies:
[source,xml]
org.eclipse.jnosql.mapping mongodb-extension 1.0.0-b4 ----=== Converter
In this extension, you have the option to convert to/from the MongoDB ObjectID.
[source,java]
@entity
public class Music {
@Id
@Convert(ObjectIdConverter.class)
private String id;
}
=== CriteriaQuery API
Also, you can use the experimental Criteria API, largely inspired by the JPA one.
Using this API you can execute queries built via CriteriaQuery.
The CriteriaQuery is used in combination with Metamodel Attributes.
These attributes are automagically generated from the defined NoSQL Entities, by including the Metamodel Processor extension as an optional dependency.
=== EntityQuery
You can fetch entities with an EntityQuery:
[source,java]
CriteriaQuery personQuery = template.createQuery(Person.class);
EntityQueryResult executeQuery = template.executeQuery(
personQuery.select().where(
personQuery.from().get(
Person_.name
).equal(
"Poliana"
).or(
personQuery.from().get(
Person_.age
).greaterThanOrEqualTo(17)
)
)
);
Stream stream = executeQuery.getEntities();
=== ExpressionQuery
You can fetch single columns/projections using an ExpressionQuery:
[source,java]
CriteriaQuery personQuery = template.createQuery(Person.class);
StringExpression<Person, Person> nameExpression = personQuery.from().get(
Person_.name
);
NumberExpression<Person, Person, Integer> ageExpression = personQuery.from().get(
Person_.age
);
ExpressionQueryResult executeQuery = template.executeQuery(
personQuery.select(
nameExpression,
ageExpression
).where(
nameExpression.equal(
"Poliana"
).or(
ageExpression.greaterThanOrEqualTo(17)
)
)
);
Optional<ExpressionQueryResultRow> findFirst = executeQuery.getRows().findFirst();
String name = findFirst.get().get(
nameExpression
);
Integer age = findFirst.get().get(
ageExpression
);
== OrientDB
image::https://jnosql.github.io/img/logos/orientdb.png[OriendtDB Project,align="center" ,align="center" width=25%, height=25%]
=== How To Install
You can use either the Maven or Gradle dependencies:
[source,xml]
org.eclipse.jnosql.mapping orientdb-extension 1.0.0-b4 ----=== Provide OrientDB Manager to the CDI Container
[source,java]
public class OrientDBProducer {
@Produces
public OrientDBDocumentCollectionManager getManager() {
OrientDBDocumentCollectionManager manager = // instance
return manager;
}
@Produces
public OrientDBDocumentCollectionManagerAsync getManagerAsync() {
OrientDBDocumentCollectionManagerAsync managerAsync = // instance
return managerAsync;
}
}
=== Repository
The OrientDBCrudRepository interface is an extension of the Repository interface that allows execution of a SQL Query via the @SQL annotation.
[source,java]
interface PersonRepository extends OrientDBCrudRepository<Person, String> {
@SQL("select * from Person")
List<Person> findAll();
@SQL("select * from Person where name = ?")
List<Person> findByName(String name);
@SQL("select * from Person where age = :age")
List<Person> findByAge(@Param("age") Integer age);
}
=== Template
The OrientDBTemplate interface is a specialization of the DocumentTemplate interface that allows execution of a SQL query and live query on both synchronous and asynchronous.
[source,java]
@Inject
OrientDBTemplate template;
...
Stream stream = template.sql("select * from Person where name = ?", "Ada");
template.live("select from Person where name = ?", callBack, "Ada");
== Solr
image::https://jnosql.github.io/img/logos/solr.svg[Solr Project,align="center" width=25%, height=25%]
The Apache Solr extension provides an implementation to define specific behavior that is beyond the scope of the API such as Search query.
=== How To Install
You can use either the Maven or Gradle dependencies:
[source,xml]
org.eclipse.jnosql.mapping solr-extension 1.0.0-b4 ----=== Provide Couchbase Manager to the CDI Container
[source,java]
public class SolrProducer {
@Produces
public SolrDocumentCollectionManager getManager() {
CouchbaseDocumentCollectionManager manager = // instance
return manager;
}
}
=== Repository
The SolrRepository interface is an extension of the Repository interface that allows using Solr query annotation that executes Solr query.
[source,java]
interface PersonRepository extends SolrRepository<Person, String> {
@Solr("select * from Person")
List<Person> findAll();
@Solr("select * from Person where name = $name")
List<Person> findByName(@Param("name") String name);
}
=== Template
The SolrTemplate interface is a specialization of the DocumentTemplate that allows execution of a Solr query.