Amber's persistence based on JPA (the Java Persistence
Architecture) supports a field-based relational model: each Java field
represents a database column. The tutorial shows the configuration,
classes, and client code for a single-table entity.
Basic persistence example showing configuration, classes, and client code for a single-table bean.
This example focuses on:
- Introduces persistence fundamental concepts
- Setting up the database
- Developing the Entity classes
- Developing a Servlet to lookup and use the entity bean
- Configuring Resin to deploy the bean and use JNDI
The Amber Query API resembles the JDBC PreparedStatement with
enhanced SQL and direct support for objects.
The Many-to-One link is the foundation of persistent relations.
It links a source table to a destination with a database REFERENCES column.
Many-to-One adds two capabilities: SQL extensions for links and direct lookup of target beans through field references.
The @OneToMany relation adds collection extensions to the query language
and provides a Java Collection containing the children. @OneToMany
represents a collection of children belonging to a parent,
like students in Gryffindor house at Hogwarts school.
The Many-To-One tutorial
illustrated that a many-to-one relation links one source entity to another
target entity. A one-to-many relation links the target entity back to the
source entity.
In this example,
each House has many Students,
each Student has one House.
House has a one-to-many relationship with Student,
Student has a many-to-one relationship with House
Illustrates using many-to-many relations of EJB 3.0.
Amber supports database-backed inheritance, allowing
for persistent-backed polymorphism and more sophisticated
object-oriented modelling.
The example uses a single table to represent both Student
and Prefect values. The "type" column serves as a discriminator to
select the proper type.
HttpSessions combined with Amber improve the flexibility and
performance of persistent sessions.