Fast implementation of object persistence with the help of Beankeeper

Source: Internet
Author: User
Tags inheritance object model

Introduction

Netmind Beankeeper is an open source Java object/Relational database mapping framework that helps users quickly save objects to a relational database, and it also supports custom queries and transactions to meet the needs of users in a variety of scenarios. Its biggest feature is simplicity, without configuration. At the same time, it is pure Java, but also support HSQLDB and MySQL and other relational databases. This article will introduce the basic principles and architecture of beankeeper, compare it with other frameworks such as Hibernate, Spring, and summarize its main advantages. Finally, we will demonstrate a case study of how to save Java objects to a relational database with the help of Beankeeper shortcut implementations.

The architecture of the Beankeeper

Object persistence is almost always a prerequisite for all Java™ applications, from desktop applications to enterprise-class applications, and the disadvantage of persistence is that it is never easy.

The Object-oriented development method is the mainstream development method in the enterprise application development environment, and the relational database is the main data storage system which holds the data permanently in enterprise application environment. object and relational data are two representations of business entities, and business entities are represented as objects in memory, and relational data are represented in the database. There is an association and inheritance relationship between objects in memory, and in a database, relational data cannot directly express Many-to-many associations and inheritance relationships. Therefore, you need an ORM (Object relational Mapping) Implementation object to the relational database data mapping.

Since the relational database is the most popular storage system at the moment, to persist the object to the relational database, we need to solve the ORM problem. The current mainstream ORM framework is: Spring, Hibernate and other frameworks. They all have one problem: it's too complicated. To use these frameworks for object persistence, developers first read the hundreds of-page document to learn how to use these frameworks, and then write an XML configuration mapping file to tell the framework if and when it is ORM. Also, once the object model has changed, the mapping file is modified. These have greatly increased the learning curve and workload of the developer and are prone to error. The idea of the Bean keeper is simple to do, and it simplifies these operations as much as possible.

The Bean Keeper is an Open-source software based on the LGPL protocol, which has the following characteristics:

Easy to use, you only need to learn 3 excuses to master the use of the basic methods;

0 configuration. In addition to the connection URL for the database. You don't need any other configuration;

Scalability, a class library that supports distributed operations and allows you to carry out multiple-copy storage and load balancing of your data;

100% Transparent support List, MAP, set, etc. set;

Automatic paging large data sets. Pagination is 100% transparent, data sets containing millions records can be directly given to the presentation layer without worrying about memory and database load problems;

Custom object-oriented Query Language, users do not need to write complex SQL statements;

Portability across a variety of databases. Beankeeper masks differences between various databases, such as handling null values, empty strings (Oracle), case-sensitive queries, and reserved words. This means you can change the underlying database;

Support for transactions that enable transactions to be committed and rolled back.

Download Beankeeper

The Beankeeper installation process is simple. First, visit the Beankeeper site to download the Jar pack. The current release is 2.6.0. All the examples in this article are also based on this version.

Beankeeper is based on the LGPL protocol, and you can use it in your business software through a class library reference (link) without the need for Open-source business software code. But if you modify its code or derive it, all modified code, additional code involving the modification, and derived code must adopt the LGPL protocol.

Figure 1. Beankeeper Current Version

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.