Skip to content

Commit

Permalink
docs: upgrade readme and remove graph reference
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <otaviopolianasantana@gmail.com>
  • Loading branch information
otaviojava committed Aug 10, 2024
1 parent 15e04c5 commit 2c47237
Showing 1 changed file with 0 additions and 110 deletions.
110 changes: 0 additions & 110 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -464,116 +464,6 @@ public DocumentManager getManagerB() {
}
----

=== Graph

Currently, the Jakarta NoSQL doesn't define an API for Graph database types but Eclipse JNoSQL provides a Graph template to explore the specific behavior of this NoSQL type.

Eclipse JNoSQL offers a mapping implementation for Graph NoSQL types:

[source,xml]
----
<dependency>
<groupId>org.eclipse.jnosql.mapping</groupId>
<artifactId>jnosql-mapping-graph</artifactId>
<version>1.1.1</version>
</dependency>
----

Despite the other three NoSQL types, Eclipse JNoSQL API does not offer a communication layer for Graph NoSQL types. Instead, it integrates with https://tinkerpop.apache.org/[Apache Tinkerpop 3.x].

[source,java]
----
@Inject
GraphTemplate template;
...
Category java = Category.of("Java");
Book effectiveJava = Book.of("Effective Java");
template.insert(java);
template.insert(effectiveJava);
EdgeEntity edge = template.edge(java, "is", software);
Stream<Book> books = template.getTraversalVertex()
.hasLabel("Category")
.has("name", "Java")
.in("is")
.hasLabel("Book")
.getResult();
----

Apache TinkerPop is database agnostic. Thus, you can change the database in your application with no or minimal impact on source code.

You can define the database settings using the https://microprofile.io/microprofile-config/[MicroProfile Config] specification, so you can add properties and overwrite it in the environment following the https://12factor.net/config[Twelve-Factor App].

[source,properties]
----
jnosql.graph.provider=<CLASS-DRIVER>
jnosql.provider.host=<HOST>
jnosql.provider.user=<USER>
jnosql.provider.password=<PASSWORD>
----

TIP: The ```jnosql.graph.provider``` property is necessary when you have more than one driver in the classpath. Otherwise, it will take the first one.

These configuration settings are the default behavior. Nevertheless, there is an option to programmatically configure these settings. Create a class that implements the ```Supplier<Graph>```, then define it using the ```@Alternative``` and ```@Priority``` annotations.

[source,java]
----
@Alternative
@Priority(Interceptor.Priority.APPLICATION)
public class ManagerSupplier implements Supplier<Graph> {
@Produces
public Graph get() {
Graph graph = ...; // from a provider
return graph;
}
}
----

You can work with several document database instances through CDI qualifier. To identify each database instance, make a `Graph` visible for CDI by putting the ```@Produces``` and the ```@Database``` annotations in the method.

[source,java]
----
@Inject
@Database(value = DatabaseType.GRAPH, provider = "databaseA")
private GraphTemplate templateA;
@Inject
@Database(value = DatabaseType.GRAPH, provider = "databaseB")
private GraphTemplate templateB;
// producers methods
@Produces
@Database(value = DatabaseType.GRAPH, provider = "databaseA")
public Graph getManagerA() {
return manager;
}
@Produces
@Database(value = DatabaseType.GRAPH, provider = "databaseB")
public Graph getManagerB() {
return manager;
}
----


Eclipse JNoSQL does not provide https://mvnrepository.com/artifact/org.apache.tinkerpop/gremlin-core[Apache Tinkerpop 3 dependency]; check if the provider does. Otherwise, do it manually.

[source,xml]
----
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>jnosql-gremlin-core</artifactId>
<version>${tinkerpop.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>jnosql-gremlin-groovy</artifactId>
<version>${tinkerpop.version}</version>
</dependency>
----

=== Jakarta Data

Expand Down

0 comments on commit 2c47237

Please sign in to comment.