DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. Databases
  4. What's New In Eclipse JNoSQL 0.0.6

What's New In Eclipse JNoSQL 0.0.6

Read this article in order to learn more about what's new in the release of Eclipse JNoSQL 0.0.6.

Otavio Santana user avatar by
Otavio Santana
CORE ·
Jul. 02, 18 · News
Like (4)
Save
Tweet
Share
12.51K Views

Join the DZone community and get the full member experience.

Join For Free

Eclipse JNoSQL is a framework that makes the integration between Java and NoSQL easier with an extensible API that allows both to use common features as standards calls and expandable enough to allow to use particular features from any specific vendor. The version 0.0.6 comes with the hot query as text. This post will cover this release.

The hottest release at this version was the query by String, explained here. This feature creates a text query that uses the standard API. Briefly, it converts the text query to a method at an entity manager.

Image title

So beyond the Graph, that already has gremlin as Graph query, each NoSQL database type API has a specific query.

DocumentTemplate documentTemplate = ..;
ColumnTemplate columnTemplate = ...;
KeyValueTempalte keyValueTemplate =...;
GraphTemplate graphTemplate =...;
List<Movie> movies = documentTemplate.query("select * from Movie where year > 2012");
List<Person> people = columnTemplate.query("select * from Person where id = 12");
Optional<God> god = keyValueTemplate.query("get \"Diana\"");
List<City> cities = graphTemplate.query("g.V().hasLabel('City')");

To run a query dynamically, use the prepare method. It will return a PreparedStatement interface. To define a parameter to key-value, document, and column query, use the "@" in front of the name.

PreparedStatement preparedStatement = documentTemplate.prepare("select * from Person where name = @name");
preparedStatement.bind("name", "Ada");
List<Person> adas = preparedStatement.getResultList();
//to graph just keep using gremlin
PreparedStatement prepare = graphTemplate().prepare("g.V().hasLabel(param)");
prepare.bind("param", "Person");
List<Person> people = preparedStatement.getResultList();

Repository

The Repository interface contains all the trivial methods shared among the NoSQL implementations that a developer does not need to care about. Also, there is query method that does a query based on the method name. The next version brought two new annotations: the Query and param that defines the statement and set the values in the query respectively.

 interface PersonRepository extends Repository<Person, Long> {
        @Query("select * from Person")
        Optional<Person> findByQuery();
        @Query("select * from Person where id = @id")
        Optional<Person> findByQuery(@Param("id") String id);
}

Remember, when a developer defines who that repository will be implemented from, the CDI qualifier, the query will be executed to that defined type, eg. gremlin to Graph, JNoSQL key to key-value, and so on.

@Inject
@Database(value = DatabaseType.COLUMN)
private PersonRepository repository;

Conclusion

This article covered how a Java developer can make a smooth integration between Java and NoSQL with Eclipse JNoSQL. At this version, query as the text was the most expected feature. This feature allows a single consult in the database. However, that does forget the particular query that each NoSQL provider has. It is important to point out the focus of the frameworks is to make the integration easier, but the NoSQL about the database is still required. To the next step, more databases are expected and also the possibility to create the API and get it in in the Jakarta EE process, despite the need to wait for the EE4P specification process.

Click here to learn more about this version.

Database Eclipse

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Upgrade Guide To Spring Data Elasticsearch 5.0
  • Hackerman [Comic]
  • Real-Time Stream Processing With Hazelcast and StreamNative
  • What Is Policy-as-Code? An Introduction to Open Policy Agent

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: