Skip to content

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.

License

Notifications You must be signed in to change notification settings

amoscatelli/jnosql-mapping-extension

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mapping Extension API

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.

ArangoDB

Arangodb Project

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).

How To Install

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");
    }
}

Repository

The ArangoDBRepository interface is an extension of the Repository interface that allows execution of AQL via the @AQL annotation.

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.

@Inject
private ArangoDBTemplate template;
...
List<Person> people = template.aql("FOR p IN Person FILTER p.name = @name RETURN p", params);

Cassandra

Apache Cassandra

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.

How To Install

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");
    }
}

Repository

The CassandraRepository interface is an extension of the Repository interface that allows execution of CQL and Consistency Level via the @CQL annotation.

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.

@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

    @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.

@Inject
CassandraTemplate template;
...
template.save(person, ConsistencyLevel.ONE);

Couchbase

Couchbase Project

The Couchbase extension provides an implementation to define specific behavior that is beyond the scope of the API such as N1QL (pronounced "nickel").

How To Install

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");
    }
}

Repository

The CouchbaseRepository interface is an extension of the Repository interface that allows execution of N1QL via the @N1QL annotation.

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);

}

Template

The CouchbaseTemplate interface is a specialization of the DocumentTemplate interface that allows using N1QL on both synchronous and asynchronous.

List<Person> people = template.n1qlQuery("select * from Person where name = $name", params);

Elasticsearch

Elasticsearch Project

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:

<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");
    }
}

Template

The ElasticsearchTemplate interface is a specialization of the DocumentTemplate interface that allows using a search engine on both synchronous and asynchronous.

@Inject
ElasticsearchTemplate template;
...

QueryBuilder queryBuilder = boolQuery().filter(termQuery("name", "Ada"));
List<Person> people = template.search(queryBuilder, "Person");

Hazelcast

Hazelcast Project

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:

<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");
    }
}

Repository

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.

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"));

MongoDB

Cassandra Project

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:

<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");
    }
}

Converter

In this extension, you have the option to convert to/from the MongoDB ObjectID.

@Entity
public class Music {

    @Id
    @Convert(ObjectIdConverter.class)
    private String id;

}

OrientDB

OriendtDB Project

How To Install

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");
    }
}

Repository

The OrientDBCrudRepository interface is an extension of the Repository interface that allows execution of a SQL Query via the @SQL annotation.

    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.

@Inject
OrientDBTemplate template;
...

Stream<Person> stream = template.sql("select * from Person where name = ?", "Ada");
template.live("select from Person where name = ?", callBack, "Ada");

Solr

Solr Project

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:

<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");
    }
}

Repository

The SolrRepository interface is an extension of the Repository interface that allows using Solr query annotation that executes Solr query.

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.

@Inject
SolrTemplate template;
...
List<Person> people = template.solr("age:@age AND type:@type AND _entity:@entity", params);

Graph Connections

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>

ArangoDB

Configuration property Description

jnosql.arangodb.graph.edge

The edge collection. It uses as a prefix. E.g.:jnosql.arangodb.graph.edge.1=edge

jnosql.arangodb.graph.relationship

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

jnosql.arangodb.graph.vertex

The vertex collection. It uses as a prefix. E.g.: jnosql.arangodb.graph.vertex.1=vertex

jnosql.arangodb.graph.graph

Name of the graph to use.

jnosql.arangodb.graph.host

The database host.

jnosql.arangodb.graph.user

The user’s credential.

jnosql.arangodb.graph.password

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

Janus

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

Titan

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

Neo4j

Configuration property Description

jnosql.neo4j.host

The database host. Default: "bolt://localhost:7687"

jnosql.neo4j.user

The user’s credential. Default: "neo4j"

jnosql.neo4j.password

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

Neo4j Remote

Configuration property Description

jnosql.neo4j.host

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/

CriteriaQuery API

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.

Set dependency

  <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>

Create a CriteriaDocumentTemplate

    @Inject
    private CriteriaDocumentTemplateProducer producer;

    @Inject
    private DocumentManager documentManager;
    CriteriaDocumentTemplate template = producer.get(documentManager);

EntityQuery

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();

ExpressionQuery

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
);

About

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.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%