Apache Empire-db
Encyclopedia
Apache Empire-db is a Java library that provides a high level object oriented API for accessing Relational database management system
s (RDBMS) through JDBC. Apache Empire-db is Open Source and provided under the Apache 2.0 license from the Apache Software Foundation
.
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.
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.
The corresponding Oracle syntax SQL statement is assumed to be as follows:
This SQL statement can be created using Empire-db's command API using object model references like this:
In order to execute the query and retrieve a list of POJO's holding the query result the following code may be used:
Empire-db also supports field access through object references or obtaining query results as XML.
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.
Relational database management system
A relational database management system is a database management system that is based on the relational model as introduced by E. F. Codd. Most popular databases currently in use are based on the relational database model....
s (RDBMS) through JDBC. Apache Empire-db is Open Source and provided under the Apache 2.0 license from the Apache Software Foundation
Apache Software Foundation
The Apache Software Foundation is a non-profit corporation to support Apache software projects, including the Apache HTTP Server. The ASF was formed from the Apache Group and incorporated in Delaware, U.S., in June 1999.The Apache Software Foundation is a decentralized community of developers...
.
Compared to Object-relational mapping
Object-relational mapping
Object-relational mapping in computer software is a programming technique for converting data between incompatible type systems in object-oriented programming languages. This creates, in effect, a "virtual object database" that can be used from within the programming language...
(ORM) or other data persistence solutions such as Hibernate
Hibernate (Java)
Hibernate is an object-relational mapping library for the Java language, providing a framework for mapping an object-oriented domain model to a traditional relational database...
, iBATIS
IBATIS
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...
or TopLink
TopLink
In computing, TopLink is an object-relational mapping package for Java developers. It provides a framework for storing Java objects in a relational database or for converting Java objects to XML documents....
Empire-db does not use XML files or Java annotations to provide a mapping of plain (old) java object (POJO
Pojo
Pojo may refer to:* Pohja, the Swedish name for the Finnish municipality* POJO, abbreviation of Plain Old Java Object in computer programming...
'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
SQL
SQL is a programming language designed for managing data in relational database management systems ....
statements and their execution by the developer compared to most OR-Mapping solutions.
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
- Data model definition through a Java object model omits the need to learn XML schemas or annotations and easily allows user interceptions and extensions.
- Portable RDBMS independent record handling and command definition with support for a variety of relational databases such as OracleOracle DatabaseThe Oracle Database is an object-relational database management system produced and marketed by Oracle Corporation....
, Microsoft SQL ServerMicrosoft SQL ServerMicrosoft SQL Server is a relational database server, developed by Microsoft: It is a software product whose primary function is to store and retrieve data as requested by other software applications, be it those on the same computer or those running on another computer across a network...
, MySQLMySQLMySQL officially, but also commonly "My Sequel") is a relational database management system that runs as a server providing multi-user access to a number of databases. It is named after developer Michael Widenius' daughter, My...
, DerbyApache DerbyApache Derby is a relational database management system developed by the Apache Software Foundation that can be embedded in Java programs and used for online transaction processing. It has a 2 MB disk-space footprint.Apache Derby is developed as an open source project under the Apache 2.0 license...
, H2H2 (DBMS)H2 is a relational database management system written in Java. It can be embedded in Java applications or run in the client-server mode. The disk footprint is about 1 MB....
and HSQLDBHSQLDBHSQLDB is a relational database management system written in Java. It has a JDBC driver and supports a large subset of SQL-92 and SQL:2008 standards. It offers a fast, small database engine which offers both in-memory and disk-based tables...
(as of version 2.0.5) - DDL generation for target DBMS from object definition, either for the entire database or for individual objects such as tables, views, columns and relations.
- Type-safe API for dynamic SQL command generation allows dynamic building of SQL statements using API methods and object references only instead of string literals. This provides a high degree of type-safety which simplifies testing and maintenance.
- Reduced amount of Java code and powerful interception of field and metadata access through dynamic beans as an alternative to POJOs. This even allows data model changes (DDL) at runtime.
- Automatic tracking of record state and field modification (aka "dirty checking") to only insert/ update modified fields.
- Support for optimistic locking through timestamp column.
- No need to always work with full database entities. Build queries to provide you with the data exactly as you need it, and obtain the result for example as a list of any type of POJO with matching property setters or constructor.
- Lightweight and passive library with zero configuration footprint that allows simple integration with any architecture or framework.
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:
This SQL statement can be created using Empire-db's command API using object model references like this:
In order to execute the query and retrieve a list of POJO's holding the query result the following code may be used:
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
- Java Database ConnectivityJava Database ConnectivityJava DataBase Connectivity, commonly referred to as JDBC, is an API for the Java programming language that defines how a client may access a database. It provides methods for querying and updating data in a database. JDBC is oriented towards relational databases...
- Object-relational mappingObject-relational mappingObject-relational mapping in computer software is a programming technique for converting data between incompatible type systems in object-oriented programming languages. This creates, in effect, a "virtual object database" that can be used from within the programming language...
- HibernateHibernate (Java)Hibernate is an object-relational mapping library for the Java language, providing a framework for mapping an object-oriented domain model to a traditional relational database...
- iBATISIBATISiBATIS 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...
- TopLinkTopLinkIn computing, TopLink is an object-relational mapping package for Java developers. It provides a framework for storing Java objects in a relational database or for converting Java objects to XML documents....
- Apache StrutsApache StrutsApache Struts is an open-source web application framework for developing Java EE web applications. It uses and extends the Java Servlet API to encourage developers to adopt a model-view-controller architecture. It was originally created by Craig McClanahan and donated to the Apache Foundation in...