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 Video Library
Refcards
Trend Reports

Events

View Events Video Library

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

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Navigating NoSQL: A Pragmatic Approach for Java Developers
  • Eclipse JNoSQL 1.0.2: Empowering Java With NoSQL Database Flexibility
  • Simplify NoSQL Database Integration in Java With Eclipse JNoSQL 1.1.3
  • Achieving Inheritance in NoSQL Databases With Java Using Eclipse JNoSQL

Trending

  • The Cypress Edge: Next-Level Testing Strategies for React Developers
  • While Performing Dependency Selection, I Avoid the Loss Of Sleep From Node.js Libraries' Dangers
  • A Guide to Container Runtimes
  • Solid Testing Strategies for Salesforce Releases
  1. DZone
  2. Data Engineering
  3. Databases
  4. Understanding and Learning NoSQL Databases With Java: Three Key Benefits

Understanding and Learning NoSQL Databases With Java: Three Key Benefits

Discover how Eclipse JNoSQL assists Java developers in implementing NoSQL capabilities such as polyglot persistence into their applications.

By 
Otavio Santana user avatar
Otavio Santana
DZone Core CORE ·
May. 29, 24 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
5.8K Views

Join the DZone community and get the full member experience.

Join For Free

In today's rapidly evolving technological landscape, it is crucial for any business or application to efficiently manage and utilize data. NoSQL databases have emerged as an alternative to traditional relational databases, offering flexibility, scalability, and performance advantages. These benefits become even more pronounced when combined with Java, a robust and widely-used programming language. This article explores three key benefits of understanding and learning NoSQL databases with Java, highlighting the polyglot philosophy and its efficiency in software architecture.

Enhanced Flexibility and Scalability

One significant benefit of NoSQL databases is their capability to handle various data models, such as key-value pairs, documents, wide-column stores, and graph databases. This flexibility enables developers to select the most suitable data model for their use case. When combined with Java, a language renowned for its portability and platform independence, the adaptability of NoSQL databases can be fully utilized.

Improved Performance and Efficiency

Performance is a crucial aspect of database management, and NoSQL databases excel in this area because of their distributed nature and optimized storage mechanisms. When developers combine these performance-enhancing features with Java, they can create applications that are not only efficient but also high-performing.

Embracing the Polyglot Philosophy

The polyglot philosophy in software development encourages using multiple languages, frameworks, and databases within a single application to take advantage of each one's strengths. Understanding and learning NoSQL databases with Java perfectly embodies this approach, offering several benefits for modern software architecture.

Leveraging Eclipse JNoSQL for Success With NoSQL Databases and Java

To fully utilize NoSQL databases with Java, developers can use Eclipse JNoSQL, a framework created to streamline the integration and management of NoSQL databases in Java applications. Eclipse JNoSQL supports over 30 databases and is aligned with Jakarta NoSQL and Jakarta Data specifications, providing a comprehensive solution for modern data handling needs.

Eclipse JNoSQL: Bridging Java and NoSQL Databases

Eclipse JNoSQL is a framework that simplifies the interaction between Java applications and NoSQL databases. With support for over 30 different NoSQL databases, Eclipse JNoSQL enables developers to work efficiently across various data stores without compromising flexibility or performance.

Key features of Eclipse JNoSQL include:

  • Support for Jakarta Data Query Language: This feature enhances the power and flexibility of querying across databases.
  • Cursor pagination: Processes large datasets efficiently by utilizing cursor-based pagination rather than traditional offset-based pagination
  • NoSQLRepository: Simplifies the creation and management of repository interfaces
  • New column and document templates: Simplify data management with predefined templates

Jakarta NoSQL and Jakarta Data Specifications

Eclipse JNoSQL is designed to support Jakarta NoSQL and Jakarta Data specifications, standardizing and simplifying database interactions in Java applications.

  • Jakarta NoSQL: This comprehensive framework offers a unified API and a set of powerful annotations, making it easier to work with various NoSQL data stores while maintaining flexibility and productivity.
  • Jakarta Data: This specification provides an API for easier data access across different database types, enabling developers to create custom query methods on repository interfaces.

Introducing Eclipse JNoSQL 1.1.1

The latest release, Eclipse JNoSQL 1.1.1, includes significant enhancements and new features, making it a valuable tool for Java developers working with NoSQL databases. Key updates include:

  • Support to cursor pagination
  • Support to Jakarta Data Query
  • Fixes several bugs and enhances performance

For more details, visit the Eclipse JNoSQL Release 1.1.1 notes.

Practical Example: Java SE Application With Oracle NoSQL

To illustrate the practical use of Eclipse JNoSQL, let's consider a Java SE application using Oracle NoSQL. This example showcases the effectiveness of cursor pagination and JDQL for querying.

The first pagination method we will discuss is Cursor pagination, which offers a more efficient way to handle large datasets than traditional offset-based pagination. Below is a code snippet demonstrating cursor pagination with Oracle NoSQL.

Java
 
@Repository
public interface BeerRepository extends OracleNoSQLRepository<Beer, String> {
    @Find
    @OrderBy("hop")
    CursoredPage<Beer> style(@By("style") String style, PageRequest pageRequest);

    @Query("From Beer where style = ?1")
    List<Beer> jpql(String style);
}

public class App4 {
    public static void main(String[] args) {
        var faker = new Faker();
        try (SeContainer container = SeContainerInitializer.newInstance().initialize()) {
            BeerRepository repository = container.select(BeerRepository.class).get();
            for (int index = 0; index < 100; index++) {
                Beer beer = Beer.of(faker);
                // repository.save(beer);
            }

            PageRequest pageRequest = PageRequest.ofSize(3);
            var page1 = repository.style("Stout", pageRequest);
            System.out.println("Page 1");
            page1.forEach(System.out::println);

            PageRequest pageRequest2 = page1.nextPageRequest();
            var page2 = repository.style("Stout", pageRequest2);
            System.out.println("Page 2");
            page2.forEach(System.out::println);

            System.out.println("JDQL query: ");
            repository.jpql("Stout").forEach(System.out::println);
        }

        System.exit(0);
    }
}


In this example, BeerRepository efficiently retrieves and paginates data using cursor pagination. The style method employs cursor pagination, while the jpql method demonstrates a JDQL query.

API Changes and Compatibility Breaks in Eclipse JNoSQL 1.1.1

The release of Eclipse JNoSQL 1.1.1 includes significant updates and enhancements aimed at improving functionality and aligning with the latest specifications. However, it's important to note that these changes may cause compatibility issues for developers, which need to be understood and addressed in their projects.

1. Annotations Moved to Jakarta NoSQL Specification

Annotations like Embeddable and Inheritance were previously included in the Eclipse JNoSQL framework. In the latest version, however, they have been relocated to the Jakarta NoSQL specification to establish a more consistent approach across various NoSQL databases. As a result, developers will need to update their imports and references to these annotations.

Java
 
// Old import
import org.jnosql.mapping.Embeddable;

// New import
import jakarta.nosql.Embeddable;


  • The updated annotations can be accessed at the Jakarta NoSQL GitHub repository.

2. Unified Query Packages

To simplify and unify the query APIs, SelectQuery and DeleteQuery have been consolidated into a single package. Consequently, specific query classes like DocumentQuery, DocumentDeleteQuery, ColumnQuery, and ColumnDeleteQuery have been removed.

  • Impact: Any code using these removed classes will no longer compile and must be refactored to use the new unified classes.
  • Solution: Refactor your code to use the new query classes in the org.eclipse.jnosql.communication.semistructured package. For example:
Java
 
// Old usage
DocumentQuery query = DocumentQuery.select().from("collection").where("field").eq("value").build();

// New usage
SelectQuery query = SelectQuery.select().from("collection").where("field").eq("value").build();


  • Similar adjustments will be needed for delete queries.

3. Migration of Templates

Templates such as ColumnTemplate, KeyValueTemplate, and DocumentTemplate have been moved from the Jakarta Specification to Eclipse JNoSQL. 

Java
 
// Old import
import jakarta.nosql.document.DocumentTemplate;

// New import
import org.eclipse.jnosql.mapping.document.DocumentTemplate;


4. Default Query Language: Jakarta Data Query Language (JDQL)

Another significant update in Eclipse JNoSQL 1.1.1 is the adoption of Jakarta Data Query Language (JDQL) as the default query language. JDQL provides a standardized way to define queries using annotations, making it simpler and more intuitive for developers.

Conclusion

The use of a NoSQL database is a powerful asset in modern applications. It allows software architects to employ polyglot persistence, utilizing the best persistence capability in each scenario. Eclipse JNoSQL assists Java developers in implementing these NoSQL capabilities into their applications.

Eclipse NoSQL Query language Relational database Java (programming language)

Opinions expressed by DZone contributors are their own.

Related

  • Navigating NoSQL: A Pragmatic Approach for Java Developers
  • Eclipse JNoSQL 1.0.2: Empowering Java With NoSQL Database Flexibility
  • Simplify NoSQL Database Integration in Java With Eclipse JNoSQL 1.1.3
  • Achieving Inheritance in NoSQL Databases With Java Using Eclipse JNoSQL

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • [email protected]

Let's be friends: