Apache Empire-db

Last updated
Apache Empire-db
Developer(s) Apache Software Foundation
Stable release
3.0.0 / March 11, 2022;21 months ago (2022-03-11)
Repository EmpireDB Repository
Written in Java
Operating system Cross-platform
Type Persistence Framework
License Apache License 2.0
Website empire-db.apache.org

Apache Empire-db is a Java library that provides a high level object-oriented API for accessing relational database management systems (RDBMS) through JDBC. Apache Empire-db is open source and provided under the Apache License 2.0 from the Apache Software Foundation.

Contents

Compared to Object-relational mapping (ORM) or other data persistence solutions such as Hibernate, iBATIS or TopLink Empire-db does not use XML files or Java annotations to provide a mapping of plain (old) Java object (POJO's) to database tables, views and columns. Instead Empire-db uses a Java object model to describe the underlying data model and an API that works almost solely with object references rather than string literals.

Empire-db's aim is to provide better software quality and improved maintainability through increased compile-time safety and reduced redundancy of metadata. Additionally applications may benefit from better performance due to full control over SQL statements and their execution by the developer compared to most OR-mapping solutions. [1]

Major benefits

Empire-db's key strength is its API for dynamic SQL generation for arbitrary select, update, insert or delete statements, purely by using Java methods which reference the model objects. This provides type-safety and almost entirely eliminates the use of string literals for names or expressions in code. Additionally DBMS independence is achieved through a pluggable driver model.

Using references to table and column objects significantly improves compile-time safety and thus reduces the amount of testing. As a positive side effect the IDE's code completion can be used to browse the data model, increases productivity and eliminates the need for other external tools or IDE-plugins.

Further the object model also provides safe and easy access to meta-information of the data model such as field data type, maximum field length, whether a field is mandatory and a finite choice of options for a field's values. Metadata is user-extensible and not limited to DBMS related metadata. Availability of meta-information encourages more generic code and eliminates redundancies throughout application layers.

Features at a glance

Example

As an example consider a database with two tables called Employees and Departments for which a list of employees in a particular format, with certain constraints and a given order should be retrieved.

The corresponding Oracle syntax SQL statement is assumed to be as follows:

SELECTt1.EMPLOYEE_ID,t1.LASTNAME||', '||t1.FIRSTNAMEASNAME,t2.DEPARTMENTFROM(EMPLOYEESt1INNERJOINDEPARTMENTSt2ONt1.DEPARTMENT_ID=t2.DEPARTMENT_ID)WHEREupper(t1.LASTNAME)LIKEupper('Foo%')ANDt1.RETIRED=0ORDERBYt1.LASTNAME,t1.FIRSTNAME

This SQL statement can be created using Empire-db's command API using object model references like this:

SampleDBdb=getDatabase();// Declare shortcuts (not necessary but convenient)SampleDB.EmployeesEMP=db.EMPLOYEES;SampleDB.DepartmentsDEP=db.DEPARTMENTS;// Create a command objectDBCommandcmd=db.createCommand();// Select columnscmd.select(EMP.EMPLOYEE_ID);cmd.select(EMP.LASTNAME.append(", ").append(EMP.FIRSTNAME).as("NAME"));cmd.select(DEP.DEPARTMENT);// Join tablescmd.join(EMP.DEPARTMENT_ID,DEP.DEPARTMENT_ID);// Set constraintscmd.where(EMP.LASTNAME.likeUpper("Foo%"));cmd.where(EMP.RETIRED.is(false));// Set ordercmd.orderBy(EMP.LASTNAME);cmd.orderBy(EMP.FIRSTNAME);

In order to execute the query and retrieve a list of POJO's holding the query result the following code may be used:

// Class definition for target objectspublicclassEmployeeInfo{privateintemployeeId;privateStringname;privateStringdepartment;// Getter's and Setters for all properties// or a public Constructor using fieldspublicget...publicset...}// Retrieve employee list using the cmd object created aboveDBReaderreader=newDBReader();try{reader.open(cmd,getConnection());List<EmployeeInfo>empList=reader.getBeanList(EmployeeInfo.class);}finally{reader.close()}

Empire-db also supports field access through object references or obtaining query results as XML.

History

Empire-db was originally developed at ESTEAM Software a German software development company which used Empire-db to develop various applications for a variety of different branches.

In January 2008 Empire-db was made officially open source and first published though SourceForge.net.

In June 2008 a proposal was submitted to the Apache Software Foundation for Empire-db to become an Apache Incubator project. In July 2008 Empire-db got accepted for incubation and all rights over the Software were transferred to the Apache Foundation.

In October 2008 Empire-db 2.0.4 was the first official Apache incubator release with all package names changed to begin with org.apache.empire.

See also

Related Research Articles

<span class="mw-page-title-main">Database</span> Organized collection of data in computing

In computing, a database is an organized collection of data or a type of data store based on the use of a database management system (DBMS), the software that interacts with end users, applications, and the database itself to capture and analyze the data. The DBMS additionally encompasses the core facilities provided to administer the database. The sum total of the database, the DBMS and the associated applications can be referred to as a database system. Often the term "database" is also used loosely to refer to any of the DBMS, the database system or an application associated with the database.

<span class="mw-page-title-main">Object database</span> Type of database management system

An object database or object-oriented database is a database management system in which information is represented in the form of objects as used in object-oriented programming. Object databases are different from relational databases which are table-oriented. A third type, object–relational databases, is a hybrid of both approaches. Object databases have been considered since the early 1980s.

A relational database is a database based on the relational model of data, as proposed by E. F. Codd in 1970. A system used to maintain relational databases is a relational database management system (RDBMS). Many relational database systems are equipped with the option of using SQL for querying and updating the database.

<span class="mw-page-title-main">Object–relational database</span> Database management system

An object–relational database (ORD), or object–relational database management system (ORDBMS), is a database management system (DBMS) similar to a relational database, but with an object-oriented database model: objects, classes and inheritance are directly supported in database schemas and in the query language. In addition, just as with pure relational systems, it supports extension of the data model with custom data types and methods.

EGL, originally developed by IBM and now available as the EDT open source project under the Eclipse Public License (EPL), is a programming technology designed to meet the challenges of modern, multi-platform application development by providing a common language and programming model across languages, frameworks, and runtime platforms.

Hibernate ORM is an object–relational mapping tool for the Java programming language. It provides a framework for mapping an object-oriented domain model to a relational database. Hibernate handles object–relational impedance mismatch problems by replacing direct, persistent database accesses with high-level object handling functions.

iBATIS is a persistence framework which automates the mapping between SQL databases and objects in Java, .NET, and Ruby on Rails. In Java, the objects are POJOs. The mappings are decoupled from the application logic by packaging the SQL statements in XML configuration files. The result is a significant reduction in the amount of code that a developer needs to access a relational database using lower level APIs like JDBC and ODBC.

A spatial database is a general-purpose database that has been enhanced to include spatial data that represents objects defined in a geometric space, along with tools for querying and analyzing such data.

An entity–attribute–value model (EAV) is a data model optimized for the space-efficient storage of sparse—or ad-hoc—property or data values, intended for situations where runtime usage patterns are arbitrary, subject to user variation, or otherwise unforeseeable using a fixed design. The use-case targets applications which offer a large or rich system of defined property types, which are in turn appropriate to a wide set of entities, but where typically only a small, specific selection of these are instantiated for a given entity. Therefore, this type of data model relates to the mathematical notion of a sparse matrix.

Jakarta Persistence is a Jakarta EE application programming interface specification that describes the management of relational data in enterprise Java applications.

A document-oriented database, or document store, is a computer program and data storage system designed for storing, retrieving and managing document-oriented information, also known as semi-structured data.

An embedded database system is a database management system (DBMS) which is tightly integrated with an application software; it is embedded in the application. It is a broad technology category that includes:

Java Database Connectivity (JDBC) is an application programming interface (API) for the Java programming language which defines how a client may access a database. It is a Java-based data access technology used for Java database connectivity. It is part of the Java Standard Edition platform, from Oracle Corporation. It provides methods to query and update data in a database, and is oriented toward relational databases. A JDBC-to-ODBC bridge enables connections to any ODBC-accessible data source in the Java virtual machine (JVM) host environment.

<span class="mw-page-title-main">Super column family</span>

A super column family is a NoSQL object that contains column families. It is a tuple (pair) that consists of a key–value pair, where the key is mapped to a value that are column families. In analogy with relational databases, a super column family is something like a "view" on a number of tables. It can also be seen as a map of tables.

<span class="mw-page-title-main">Apache Drill</span> Open-source software framework

Apache Drill is an open-source software framework that supports data-intensive distributed applications for interactive analysis of large-scale datasets. Built chiefly by contributions from developers from MapR, Drill is inspired by Google's Dremel system. Drill is an Apache top-level project. Tom Shiran is the founder of the Apache Drill Project. It was designated an Apache Software Foundation top-level project in December 2016.

Rocket U2 is a suite of database management (DBMS) and supporting software now owned by Rocket Software. It includes two MultiValue database platforms: UniData and UniVerse. Both of these products are operating environments which run on current Unix, Linux and Windows operating systems. They are both derivatives of the Pick operating system. The family also includes developer and web-enabling technologies including SB/XA, U2 Web Development Environment (WebDE), UniObjects connectivity API and wIntegrate terminal emulation software.

The following outline is provided as an overview of and topical guide to MySQL:

Oracle TopLink is a mapping and persistence framework for Java developers. TopLink is produced by Oracle and is a part of Oracle's OracleAS, WebLogic, and OC4J servers. It is an object-persistence and object-transformation framework. TopLink provides development tools and run-time functionalities that ease the development process and help increase functionality. Persistent object-oriented data is stored in relational databases which helps build high-performance applications. Storing data in either XML or relational databases is made possible by transforming it from object-oriented data.

References

  1. "Apache Empire-db". empire-db.apache.org. Retrieved 2022-03-21.