Skip to content

Commit 48a4587

Browse files
committed
docs: include apachre graph info
Signed-off-by: Otavio Santana <[email protected]>
1 parent 1541e1a commit 48a4587

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

README.adoc

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,6 +1701,118 @@ SolrTemplate template;
17011701
List<Person> people = template.solr("age:@age AND type:@type AND _entity:@entity", params);
17021702
----
17031703

1704+
1705+
=== Graph (Apache Tinkerpop)
1706+
1707+
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.
1708+
1709+
Eclipse JNoSQL offers a mapping implementation for Graph NoSQL types:
1710+
1711+
[source,xml]
1712+
----
1713+
<dependency>
1714+
<groupId>org.eclipse.jnosql.mapping</groupId>
1715+
<artifactId>jnosql-mapping-graph</artifactId>
1716+
<version>1.1.1</version>
1717+
</dependency>
1718+
----
1719+
1720+
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].
1721+
1722+
[source,java]
1723+
----
1724+
@Inject
1725+
GraphTemplate template;
1726+
...
1727+
1728+
Category java = Category.of("Java");
1729+
Book effectiveJava = Book.of("Effective Java");
1730+
1731+
template.insert(java);
1732+
template.insert(effectiveJava);
1733+
EdgeEntity edge = template.edge(java, "is", software);
1734+
1735+
Stream<Book> books = template.getTraversalVertex()
1736+
.hasLabel("Category")
1737+
.has("name", "Java")
1738+
.in("is")
1739+
.hasLabel("Book")
1740+
.getResult();
1741+
----
1742+
1743+
Apache TinkerPop is database agnostic. Thus, you can change the database in your application with no or minimal impact on source code.
1744+
1745+
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].
1746+
1747+
[source,properties]
1748+
----
1749+
jnosql.graph.provider=<CLASS-DRIVER>
1750+
jnosql.provider.host=<HOST>
1751+
jnosql.provider.user=<USER>
1752+
jnosql.provider.password=<PASSWORD>
1753+
----
1754+
1755+
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.
1756+
1757+
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.
1758+
1759+
[source,java]
1760+
----
1761+
@Alternative
1762+
@Priority(Interceptor.Priority.APPLICATION)
1763+
public class ManagerSupplier implements Supplier<Graph> {
1764+
1765+
@Produces
1766+
public Graph get() {
1767+
Graph graph = ...; // from a provider
1768+
return graph;
1769+
}
1770+
}
1771+
----
1772+
1773+
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.
1774+
1775+
[source,java]
1776+
----
1777+
@Inject
1778+
@Database(value = DatabaseType.GRAPH, provider = "databaseA")
1779+
private GraphTemplate templateA;
1780+
1781+
@Inject
1782+
@Database(value = DatabaseType.GRAPH, provider = "databaseB")
1783+
private GraphTemplate templateB;
1784+
1785+
// producers methods
1786+
@Produces
1787+
@Database(value = DatabaseType.GRAPH, provider = "databaseA")
1788+
public Graph getManagerA() {
1789+
return manager;
1790+
}
1791+
1792+
@Produces
1793+
@Database(value = DatabaseType.GRAPH, provider = "databaseB")
1794+
public Graph getManagerB() {
1795+
return manager;
1796+
}
1797+
----
1798+
1799+
1800+
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.
1801+
1802+
[source,xml]
1803+
----
1804+
<dependency>
1805+
<groupId>org.apache.tinkerpop</groupId>
1806+
<artifactId>jnosql-gremlin-core</artifactId>
1807+
<version>${tinkerpop.version}</version>
1808+
</dependency>
1809+
<dependency>
1810+
<groupId>org.apache.tinkerpop</groupId>
1811+
<artifactId>jnosql-gremlin-groovy</artifactId>
1812+
<version>${tinkerpop.version}</version>
1813+
</dependency>
1814+
----
1815+
17041816
== Getting Help
17051817

17061818
Having trouble with Eclipse JNoSQL databases? We’d love to help!

0 commit comments

Comments
 (0)