The Eclipse JNoSQL Mapping Extension API is a collection of implementations/specializations from the Jakarta NoSQL specification that defines specific behavior in various NoSQL databases.
The ArangoDB extension provides an implementation to define specific behavior that is beyond the scope of the API such as the ArangoDB Query Language (AQL).
You can use either the Maven or Gradle dependencies:
<dependency>
<groupId>org.eclipse.jnosql.mapping</groupId>
<artifactId>jnosql-aragangodb-extension</artifactId>
<version>1.0.0-b5</version>
</dependency>
You can define the database settings using Eclipse MicroProfile Config, so you can put it in the properties and overwrite it in the environment following the Twelve-Factor App.
jnosql.document.database=<DATABASE>
jnosql.arangodb.host=localhost:8529
The config settings are the default behavior; nevertheless, there is an option to do it programmatically. Create a class that implements the Supplier<ArangoDBDocumentManager>
and then defines it as an @Alternative
and the Priority
.
@ApplicationScoped
@Alternative
@Priority(Interceptor.Priority.APPLICATION)
public class ManagerSupplier implements Supplier<ArangoDBDocumentManager> {
@Produces
public ArangoDBDocumentManager get() {
Settings settings = Settings.builder().put("credential", "value").build();
ArangoDBDocumentConfiguration configuration = new ArangoDBDocumentConfiguration();
ArangoDBDocumentManagerFactory factory = configuration.apply(settings);
return factory.apply("database");
}
}
The
interface is an extension of the ArangoDBRepository
interface that allows execution of AQL via the Repository
annotation.@AQL
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);
}
The Cassandra extension provides an implementation to define specific behavior that is beyond the scope of the API such as the Cassandra Query Language (CQL) and Consistency Level.
You can use either the Maven or Gradle dependencies:
<dependency>
<groupId>org.eclipse.jnosql.mapping</groupId>
<artifactId>jnosql-cassandra-extension</artifactId>
<version>1.0.0-b5</version>
</dependency>
You can define the database settings using Eclipse MicroProfile Config, so you can put it in the properties and overwrite it in the environment following the Twelve-Factor App.
jnosql.document.database=<DATABASE>
jnosql.cassandra.host.1=localhost
jnosql.cassandra.port=9142
jnosql.cassandra.query.1=CREATE KEYSPACE IF NOT EXISTS newKeySpace WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 3};
The config settings are the default behavior; nevertheless, there is an option to do it programmatically. Create a class that implements the Supplier<CassandraColumnManager>
and then defines it as an @Alternative
and the Priority
.
@ApplicationScoped
@Alternative
@Priority(Interceptor.Priority.APPLICATION)
public class ManagerSupplier implements Supplier<CassandraColumnManager> {
@Produces
public CassandraColumnManager get() {
Settings settings = Settings.builder().put("credential", "value").build();
CassandraConfiguration configuration = new CassandraConfiguration();
CassandraColumnManagerFactory factory = configuration.apply(settings);
return factory.apply("database");
}
}
The
interface is an extension of the CassandraRepository
interface that allows execution of CQL and Consistency Level via the Repository
annotation.@CQL
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);
}
The
annotation is a mapping annotation that allows defining a field to be stored as a user-defined type in Cassandra.@UDT
@Entity
public class Person {
@Id("name")
private String name;
@Column
private Integer age;
@UDT("address")
@Column
private Address home;
}
-
TimestampConverter: That converts to/from java.util.Date
-
LocalDateConverter: That converts to/from com.datastax.driver.core.LocalDate
@Column
@Convert(value = TimestampConverter.class)
private LocalDateTime localDateTime;
@Column
@Convert(value = LocalDateConverter.class)
private Calendar calendar;
The Couchbase extension provides an implementation to define specific behavior that is beyond the scope of the API such as N1QL (pronounced "nickel").
You can use either the Maven or Gradle dependencies:
<dependency>
<groupId>org.eclipse.jnosql.mapping</groupId>
<artifactId>jnosql-couchbase-extension</artifactId>
<version>1.0.0-b5</version>
</dependency>
You can define the database settings using Eclipse MicroProfile Config, so you can put it in the properties and overwrite it in the environment following the Twelve-Factor App.
jnosql.document.database=<DATABASE>
jnosql.couchbase.host=couchbase://localhost
jnosql.couchbase.user=root
jnosql.couchbase.password=123456
The config settings are the default behavior; nevertheless, there is an option to do it programmatically. Create a class that implements the Supplier<CouchbaseDocumentManager>
and then defines it as an @Alternative
and the Priority
.
@ApplicationScoped
@Alternative
@Priority(Interceptor.Priority.APPLICATION)
public class ManagerSupplier implements Supplier<CouchbaseDocumentManager> {
@Produces
public CouchbaseDocumentManager get() {
Settings settings = Settings.builder().put("credential", "value").build();
CouchbaseDocumentConfiguration configuration = new CouchbaseDocumentConfiguration();
CouchbaseDocumentManagerFactory factory = configuration.apply(settings);
return factory.apply("database");
}
}
The
interface is an extension of the CouchbaseRepository
interface that allows execution of N1QL via the Repository
annotation.@N1QL
interface PersonRepository extends CouchbaseRepository<Person, String> {
@N1QL("select * from Person")
List<Person> findAll();
@N1QL("select * from Person where name = $name")
List<Person> findByName(@Param("name") String name);
}
The Elasticsearch extension provides an implementation to define specific behavior that is beyond the scope of the API such as a search engine.
You can use either the Maven or Gradle dependencies:
<dependency>
<groupId>org.eclipse.jnosql.mapping</groupId>
<artifactId>jnosql-elasticsearch-extension</artifactId>
<version>1.0.0-b5</version>
</dependency>
You can define the database settings using Eclipse MicroProfile Config, so you can put it in the properties and overwrite it in the environment following the Twelve-Factor App.
jnosql.document.database=<DATABASE>
jnosql.elasticsearch.host.1=localhost:9200
The config settings are the default behavior; nevertheless, there is an option to do it programmatically. Create a class that implements the Supplier<ElasticsearchDocumentManager>
and then defines it as an @Alternative
and the Priority
.
@ApplicationScoped
@Alternative
@Priority(Interceptor.Priority.APPLICATION)
public class ManagerSupplier implements Supplier<ElasticsearchDocumentManager> {
@Produces
public ElasticsearchDocumentManager get() {
Settings settings = Settings.builder().put("credential", "value").build();
ElasticsearchDocumentConfiguration configuration = new ElasticsearchDocumentConfiguration();
ElasticsearchDocumentManagerFactory factory = configuration.apply(settings);
return factory.apply("database");
}
}
The
interface is a specialization of the ElasticsearchTemplate
interface that allows using a search engine on both synchronous and asynchronous.DocumentTemplate
@Inject
ElasticsearchTemplate template;
...
QueryBuilder queryBuilder = boolQuery().filter(termQuery("name", "Ada"));
List<Person> people = template.search(queryBuilder, "Person");
The Hazelcast extension provides an implementation to define specific behavior that is beyond the scope of the API such as Hazelcast Query.
You can use either the Maven or Gradle dependencies:
<dependency>
<groupId>org.eclipse.jnosql.mapping</groupId>
<artifactId>jnosql-hazelcast-extension</artifactId>
<version>1.0.0-b5</version>
</dependency>
You can define the database settings using Eclipse MicroProfile Config, so you can put it in the properties and overwrite it in the environment following the Twelve-Factor App.
jnosql.document.database=<DATABASE>
jnosql.hazelcast.instance.name=name
jnosql.hazelcast.host.1=localhost
The config settings are the default behavior; nevertheless, there is an option to do it programmatically. Create a class that implements the Supplier<HazelcastBucketManager>
and then defines it as an @Alternative
and the Priority
.
@ApplicationScoped
@Alternative
@Priority(Interceptor.Priority.APPLICATION)
public class ManagerSupplier implements Supplier<HazelcastBucketManager> {
@Produces
public HazelcastBucketManager get() {
Settings settings = Settings.builder().put("credential", "value").build();
HazelcastKeyValueConfiguration configuration = new HazelcastKeyValueConfiguration();
HazelcastBucketManagerFactory factory = configuration.apply(settings);
return factory.apply("database");
}
}
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);
}
The
interface is a specialization of the HazelcastTemplate
interface that allows execution of a Hazelcast query.KeyValueTemplate
Collection<Person> people = template.query("active");
Collection<Person> people2 = template.query("age = :age", singletonMap("age", 10));
Collection<Person> people3 = template.query(Predicates.equal("name", "Poliana"));
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.
You can use either the Maven or Gradle dependencies:
<dependency>
<groupId>org.eclipse.jnosql.mapping</groupId>
<artifactId>jnosql-mongodb-extension</artifactId>
<version>1.0.0-b5</version>
</dependency>
You can define the database settings using Eclipse MicroProfile Config, so you can put it in the properties and overwrite it in the environment following the Twelve-Factor App.
jnosql.document.database=<DATABASE>
jnosql.mongodb.host.1=localhost:27017
The config settings are the default behavior; nevertheless, there is an option to do it programmatically. Create a class that implements the Supplier<MongoDBDocumentManager>
and then defines it as an @Alternative
and the Priority
.
@ApplicationScoped
@Alternative
@Priority(Interceptor.Priority.APPLICATION)
public class ManagerSupplier implements Supplier<MongoDBDocumentManager> {
@Produces
public MongoDBDocumentManager get() {
Settings settings = Settings.builder().put("credential", "value").build();
MongoDBDocumentConfiguration configuration = new MongoDBDocumentConfiguration();
MongoDBDocumentManagerFactory factory = configuration.apply(settings);
return factory.apply("database");
}
}
You can use either the Maven or Gradle dependencies:
<dependency>
<groupId>org.eclipse.jnosql.mapping</groupId>
<artifactId>jnosql-orientdb-extension</artifactId>
<version>1.0.0-b5</version>
</dependency>
You can define the database settings using Eclipse MicroProfile Config, so you can put it in the properties and overwrite it in the environment following the Twelve-Factor App.
jnosql.document.database=<DATABASE>
jnosql.orientdb.host=localhost:27017
jnosql.orientdb.user=root
jnosql.orientdb.password=rootpwd
jnosql.orientdb.storageType=plocal
The config settings are the default behavior; nevertheless, there is an option to do it programmatically. Create a class that implements the Supplier<OrientDBDocumentManager>
and then defines it as an @Alternative
and the Priority
.
@ApplicationScoped
@Alternative
@Priority(Interceptor.Priority.APPLICATION)
public class ManagerSupplier implements Supplier<OrientDBDocumentManager> {
@Produces
public OrientDBDocumentManager get() {
Settings settings = Settings.builder().put("credential", "value").build();
OrientDBDocumentConfiguration configuration = new OrientDBDocumentConfiguration();
OrientDBDocumentManagerFactory factory = configuration.apply(settings);
return factory.apply("database");
}
}
The
interface is an extension of the OrientDBCrudRepository
interface that allows execution of a SQL Query via the Repository
annotation.@SQL
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);
}
The
interface is a specialization of the OrientDBTemplate
interface that allows execution of a SQL query and live query on both synchronous and asynchronous.DocumentTemplate
@Inject
OrientDBTemplate template;
...
Stream<Person> stream = template.sql("select * from Person where name = ?", "Ada");
template.live("select from Person where name = ?", callBack, "Ada");
The Apache Solr extension provides an implementation to define specific behavior that is beyond the scope of the API such as Search query.
You can use either the Maven or Gradle dependencies:
<dependency>
<groupId>org.eclipse.jnosql.mapping</groupId>
<artifactId>jnosql-solr-extension</artifactId>
<version>1.0.0-b5</version>
</dependency>
You can define the database settings using Eclipse MicroProfile Config, so you can put it in the properties and overwrite it in the environment following the Twelve-Factor App.
jnosql.document.database=<DATABASE>
jnosql.solr.host.1=HOST
The config settings are the default behavior; nevertheless, there is an option to do it programmatically. Create a class that implements the Supplier<SolrDocumentManager>
and then defines it as an @Alternative
and the Priority
.
@ApplicationScoped
@Alternative
@Priority(Interceptor.Priority.APPLICATION)
public class ManagerSupplier implements Supplier<SolrDocumentManager> {
@Produces
public SolrDocumentManager get() {
Settings settings = Settings.builder().put("credential", "value").build();
SolrDocumentConfiguration configuration = new SolrDocumentConfiguration();
SolrDocumentManagerFactory factory = configuration.apply(settings);
return factory.apply("database");
}
}
The
interface is an extension of the SolrRepository
interface that allows using Solr query annotation that executes Solr query.Repository
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);
}
Graph connections is a project that contains several GraphConfiguration
implementations.
<dependency>
<groupId>org.eclipse.jnosql.mapping</groupId>
<artifactId>jnosql-jnosql-graph-connections</artifactId>
<version>1.0.0-b5</version>
</dependency>
Configuration property | Description |
---|---|
|
The edge collection. It uses as a prefix. E.g.:jnosql.arangodb.graph.edge.1=edge |
|
Edge collection, the source vertex collection and the target vertex collection split by pipe. It hou,It uses as a prefix. E.g.: jnosql.arangodb.graph.relationship.1=Person|knows|Person |
|
The vertex collection. It uses as a prefix. E.g.: jnosql.arangodb.graph.vertex.1=vertex |
|
Name of the graph to use. |
|
The database host. |
|
The user’s credential. |
|
The password’s credential. |
This is an example using ArangoDB’s Graph API with MicroProfile Config.
jnosql.graph.provider=org.eclipse.jnosql.mapping.graph.connections.ArangoDBGraphConfiguration
jnosql.arangodb.graph.graph=marketing
jnosql.arangodb.graph.vertex.1=Person
jnosql.arangodb.graph.edge.1=knows
jnosql.arangodb.graph.relationship.1=Person|knows|Person
This is an example using Janus’s Graph API with MicroProfile Config.
Warning
|
The API will pass and use the properties from org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration
|
jnosql.graph.provider=org.eclipse.jnosql.mapping.graph.connections.JanusGraphConfiguration
graphname=name
allow-upgrade=false
This is an example using Titan’s Graph API with MicroProfile Config.
Warning
|
The API will pass and use the properties from com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration
|
jnosql.graph.provider=org.eclipse.jnosql.mapping.graph.connections.TitanGraphConfiguration
Configuration property | Description |
---|---|
|
The database host. Default: "bolt://localhost:7687" |
|
The user’s credential. Default: "neo4j" |
|
The password’s credential. Default: "neo4j" |
This is an example using Neo4J’s Graph API with MicroProfile Config.
jnosql.graph.provider=org.eclipse.jnosql.mapping.graph.connections.Neo4JGraphConfiguration
jnosql.neo4j.user=neo4j
jnosql.neo4j.password=neo4j
jnosql.neo4j.host=bolt://localhost:7687
Configuration property | Description |
---|---|
|
The database host. Default: "bolt://localhost:7687" |
This is an example using Neo4J’s Graph API with MicroProfile Config.
jnosql.graph.provider=org.eclipse.jnosql.mapping.graph.connections.Neo4JEmbeddedGraphConfiguration
jnosql.neo4j.host=/home/otaviojava/data/
This is 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.
The Criteria API can be used via CriteriaDocumentTemplate.
<dependency>
<groupId>org.eclipse.jnosql.mapping</groupId>
<artifactId>jnosql-metamodel-processor-extension</artifactId>
<version>1.0.0-b5</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.eclipse.jnosql.mapping</groupId>
<artifactId>jnosql-criteria-extension</artifactId>
<version>1.0.0-b5</version>
</dependency>
@Inject
private CriteriaDocumentTemplateProducer producer;
@Inject
private DocumentManager documentManager;
CriteriaDocumentTemplate template = producer.get(documentManager);
You can fetch entities with an EntityQuery :
CriteriaQuery<Person> personQuery = template.createQuery(Person.class);
EntityQueryResult<Person> executeQuery = template.executeQuery(
personQuery.select().where(
personQuery.from().get(
Person_.name
).equal(
"Poliana"
).or(
personQuery.from().get(
Person_.age
).greaterThanOrEqualTo(17)
)
)
);
Stream<Person> stream = executeQuery.getEntities();
You can fetch single columns/projections using an ExpressionQuery :
CriteriaQuery<Person> 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<Person> executeQuery = template.executeQuery(
personQuery.select(
nameExpression,
ageExpression
).where(
nameExpression.equal(
"Poliana"
).or(
ageExpression.greaterThanOrEqualTo(17)
)
)
);
Optional<ExpressionQueryResultRow<Person>> findFirst = executeQuery.getRows().findFirst();
String name = findFirst.get().get(
nameExpression
);
Integer age = findFirst.get().get(
ageExpression
);