Java Reference
In-Depth Information
Example 14.1 Candidate DB tables for BudgetPro
DROP DATABASE budgetPro;
CREATE DATABASE budgetPro;
USE DATABASE budgetPro;
CREATE TABLE Account (
id INTEGER NOT NULL,
name VARCHAR(64) NOT NULL,
user_id INTEGER NOT NULL,
amount DECIMAL,
balance DECIMAL,
parent_account_id INTEGER,
PRIMARY KEY (id),
FOREIGN KEY (user_id) REFERENCES User(id)
);
CREATE TABLE User (
id INTEGER NOT NULL,
name VARCHAR(64),
PRIMARY KEY (id)
);
We will implement this in the simplest way possible, by directly embedded
SQL statements in the application code. But this is far from your only choice.
It is possible to design a “persistence framework,” such that all classes that
inherit from a persistence base class or implement a persistence interface and
follow certain naming conventions for member data can be automatically
backed by persistent storage. Java's ability to introspect , that is, to look at the
names and structures of a class dynamically at runtime, allow one to write such
an automatic persistence framework. Several such libraries already exist, includ-
ing both commercial and Open Source options. This being an Open Source
book, we'll call you attention to the Open Source choices: 3
3. Have we tried all of these? Yeah. Sure. Why not? Of course we haven't. Don't read endorse-
ment into this or any of our “here are some choices” lists. These are also not presented in any
particular order. We tell you they exist. It is up to you to evaluate their suitability for your
purposes.
Search WWH ::




Custom Search