Skip to main content

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.

Jump to: navigation, search

Difference between revisions of "JNoSQL/Artemis/OrientDB"

Line 49: Line 49:
  
 
public void sample() {
 
public void sample() {
         List<Person> people = repository.find("select * from Person where name = ?", "Ada");
+
         List<Person> people = repository.sql("select * from Person where name = ?", "Ada");
 
}
 
}
 
</pre>
 
</pre>

Revision as of 12:47, 30 June 2017

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 OrientDBTemplate and OrientDBTemplateAsync 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 Template

OrientDBTemplate and OrientDBTemplateAsync are specialized classes from DocumentTemplate and DocumentTemplateAsync 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 OrientDBTemplate template;

public void sample() {
         List<Person> people = repository.sql("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);
    }


Repository

Beyond the document repository, OrientDB Extension also has the Repository specialization to both sync and async works. These specializations allow querying with query.


Sample Code
    public interface PersonRepository extends OrientDBRepository<Person> {

        @SQL("select * from Person")
        List<Person> findAll();

        @SQL("select * from Person where name = ?")
        List<Person> findByName(String name);
    }


   public interface PersonAsyncRepository extends OrientDBRepositoryAsync<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);
    }

Links

Back to the top