Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
JNoSQL/Artemis/OrientDB
Contents
OrientDB Extension
The goal of an extension goes beyond the Artemis API-core, and with OrientDB Extensions, it does not look different. OrientDB Extension has classes such as OrientDBDocumentRepository and OrientDBDocumentRepositoryAsync whose have support to OrientDB particular behavior as n1ql.
Maven Dependency
To use the OrientDB extension to Artemis:
<dependency>
<groupId>org.jnosql.artemis</groupId>
<artifactId>orientdb-extension</artifactId>
<version>version</version>
</dependency>
E.g:
<dependency>
<groupId>org.jnosql.artemis</groupId>
<artifactId>orientdb-extension</artifactId>
<version>0.0.1</version>
</dependency>
OrientDB Document Repository
OrientDBDocumentRepository and OrientDBDocumentRepositoryAsync are specialized classes from DocumentRepository and DocumentRepositoryAsync respectively, so they have all methods plus the OrientDB methods whose has in OrientDB driver such as query. To active, this resource just needs to produce an OrientDBDocumentCollectionManager in a CDI context.
@Produces
public OrientDBDocumentCollectionManager getManager() {
//code
return managerFactory.get(KEY_SPACE);
}
Done, the Artemis will take and manage the bean to you.
@Inject
private OrientDBDocumentRepository repository;
public void sample() {
List<Person> people = repository.find("select * from Person where name = ?", "Ada");
}
The similar thing happens with the OrientDBDocumentRepositoryAsync just produces the OrientDBDocumentCollectionManagerAsync.
@Produces
public OrientDBDocumentCollectionManagerAsync getManagerAsync() {
//code
return managerFactory.get(KEY_SPACE);
}
Crud repository
Beyond the document repository, OrientDB Extension also has the CrudRepository specialization to both sync and async works. These specializations allow querying with query.
Sample Code
public interface PersonRepository extends OrientDBCrudRepository<Person> {
@SQL("select * from Person")
List<Person> findAll();
@SQL("select * from Person where name = ?")
List<Person> findByName(String name);
}
public interface PersonRepository extends CouchbaseCrudRepository<Person> {
@N1QL("select * from Person")
List<Person> findAll();
@N1QL("select * from Person where name = $name")
List<Person> findByName(JsonObject params);
}
public interface PersonAsyncRepository extends OrientDBCrudRepositoryAsync<Person> {
Person findByName(String name);
@SQL("select * from Person where name= ?")
void queryName(String name);
@SQL("select * from Person where name= ?")
void queryName(String name, Consumer<List<Person>> callBack);
}