activeobjects.activeobjects.5.2.1-c99c271be.source-code.overview.html Maven / Gradle / Ivy
Show all versions of activeobjects Show documentation
ActiveObjects is a powerful Java
ORM (Object Relational Mapper) designed with the expressed goal of being the simplest
and easiest-to-use DB persistence layer possible in Java. Unlike JPA/Hibernate and
other popular Java ORMs which are based upon
mapping pattern,
ActiveObjects is based upon the
active record pattern
(not to be confused with the ActiveRecord ORM
popularized by Ruby on Rails). ActiveObjects has taken extensive inspiration from
ActiveRecord, Hibernate and other ORMs in its attempt to be powerful and yet
extremely simple to use.
Getting Started
Try looking in the net.java.ao
package. Most other classes are either internal to AO or part of the extended
API, allowing additional functionality. All that is needed to use ActiveObjects
for most use-cases is contained within this package. The
Entity interface and
EntityManager class are excellent
places to start in gaining a more complete understanding of the API and how
it should be used.
Unlike most Java ORMs, ActiveObjects uses dynamic interface proxies as entities,
avoiding the need for the API user to write verbose bean definitions to allow
persistence. The superinterface for the interfaces which are being proxied is ultimately
RawEntity, though Entity is more
often used as the direct superinterface. Deriving from this superclass and defining
conventional accessor/mutator methods using standard Java names and types is all
that is required to define a basic entity. This entity can then be retrieved,
persisted, etc all using the EntityManager class. Database connections
are created by DatabaseProvider,
which is managed entirely by EntityManager in most situations.
The bare minimum prerequisites to use ActiveObjects are as follows:
- One or more entity interfaces
- An EntityManager instance, created using its constructor passing
a JDBC URI and the database authentication credentials
- The appropriate JDBC driver on the classpath
- A database (bet you weren't expecting that one)
A list of supported databases can be found
here.
Connection Pooling
Connection pooling is supported by ActiveObjects, but only through the
use of third party libraries. All this means is that ActiveObjects doesn't
implement its own, clean-room pool library, but rather makes use of industry
standard implementations if available. To enable connection pooling in ActiveObjects,
all you have to do is provide one of the supported connection pooling libraries
on the classpath. ActiveObjects will automatically use this library as an
indirect to obtain database connections, providing much higher performance than
would otherwise be obtainable.
Due to the high number of connections which are created and briefly used by
ActiveObjects (a function of its design), it is highly recommended that
a connection pool library be utilized to increase performance. The use of
connection pooling mitigates the performance impact of this design decision to
a negligable level (in practice, it isn't a problem due to advanced caching
which takes place automatically within ActiveObjects).