QuickDB ORM

QuickDB
Developer(s) Diego Sarmentero
Stable release 1.2 / January 10, 2010 (2010-01-10)
Development status Active
Written in Java
Operating system Cross-platform
Type ORM
License LGPL
Website https://code.google.com/p/quickdb/
http://sites.google.com/site/quickdbdeveloper/

QuickDB is an object-relational mapping framework for the Java software platform. It was developed by Diego Sarmentero along with others and is licensed under the LGPL License. Versions for .NET, Python and PHP are also being developed.

Concepts

QuickDB allows a developer to focus on the definition of the entities that represent the tables of the database and perform operations that allow the interaction between these entities and the database without having to perform tedious configurations, leaving to the library the task to infer the object structure and make the mapping of the object to the Database.

The software aims not only to simplify the task of mapping the attributes between a traditional relational database and the objects from the data model, but in turn, make the use of the library intuitive for the developer, leaving aside configuration tasks. Where each operation involves only the task (save, modify, ...) and the subject where it should apply to (the object).

QuickDB, like other tools for object-relational mapping, seeks to resolve the differences between the two co-existing data models: Object-Oriented Model and the Relational Model. To address this problem, it takes a fully object-oriented approach, where structures like "Objects composed of other objects", "Inheritance", "Collections" (one-to-many and many-to-many) are recognized by default as common entities, and also other features such as automatic table creation and modification of tables dynamically if the structure of the object change over time (addition of new attributes) are included. QuickDB not require the implementation of any interface, or the use of inheritance by the data model to be persistent, it is based simply on certain naming conventions for attributes to infer relevant information about the Object. However, it is possible to use annotations to set certain characteristics of the object, which gives the assurance that everything that QuickDB recognize by default, can be also managed completely by the developer. For queries, QuickDB pretends to maintain this approach where the developer works with the data model in a fully object-oriented way, and therefore the SQL statements (although they are permitted) are not necessary, and can be used by default a Query system where the condition to be evaluated is specified with a simple reference to the attributes in the objects from the data model.

Capabilities

This capabilities can be combined with Inheritance, Compound Objects, Collections (Many to Many Relation, One to Many Relation) and Automatic Table Creation.

Using QuickDB

Example Classes::

//Create AdminBase instance for MySQL
AdminBase admin = new AdminBase(AdminBase.DATABASE.MYSQL, "localhost",
        "3306", "exampleQuickDB", "root", "");

//Create Address Object
Address a = new Address();
a.setNumber(123);
a.setStreet("unnamed street");

//Create a Collection of Phone Objects
Phone p1 = new Phone();
p1.setAreaCode("351");
p1.setNumber("123456");
Phone p2 = new Phone();
p2.setAreaCode("351");
p2.setNumber("4567890");
ArrayList<Phone> phones = new ArrayList<Phone>();
phones.add(p1);
phones.add(p2);

//Create Employee Object
Employee e = new Employee();
e.setCode(555);
e.setRolDescription("play ping pong");
e.setName("Diego Sarmentero");
e.setBirth(new java.sql.Date(100, 4, 20));
e.setAddress(a);
e.setPhone(phones);

Operation: save

//Create the Table automatically if not exists
admin.save(e); //Salvar Employee

Result: save

Tables are automatically created and the Employee object is saved with all the objects related to it.

Address

idstreetnumber
1 unnamed street 123

Phone

idareaCodenumber
1 351 123456
2 351 4567890

Person

idnamebirthaddress
1 Diego Sarmentero 2000-05-20 1

PersonPhone

idbaserelated
1 1 1
2 1 2

Employee

idcoderolDescriptionparent_id
1 555 play ping pong 1

Operation: obtain

The Employee object which inherited attribute address has the value "unnamed street" in street is retrieved.

admin.obtain(e, "address.street = 'unnamed street'");
admin.obtain(e).where("street", Address.class).equal("unnamed street").find();

Operation: modify

Change the name from the Employee object and add a new Phone to the collection (the obtain operation must be performed previously to retrieve the object).

e.setName("Leonardo");
Phone p = new Phone();
p.setAreaCode("123");
p.setNumber("98765");
e.getPhone().add(p);

admin.modify(e);

Operation: delete

Delete an specific Employee object (after retrieve the object with obtain operation).

admin.delete(e);

Inheritance: AdminBinding

QuickDB also provides the possibility of allowing the developer to create the data model extending the AdminBinding Class (but this is not required, this is another available resource to simplify some processes), which serves as a "link" between the entities and AdminBase to allow the operations that interact with the database to be executed from the object itself and not use AdminBase intermediary as directly.

AdminBinding not cover all the functionality that AdminBase provides, as it only handles those operations that are specific to the object that contains them, leaving out those that refer to collections, etc.

More Features

QuickDB includes many features that can be consulted on the Project Page. An important detail to take into account is that with every new feature that is added, the simplicity of QuickDB is maintained without sacrifice functionality.

External links

This article is issued from Wikipedia - version of the Tuesday, March 17, 2015. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.