13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

320Chapter 14Storing the DataExample 14.1 Candidate DB tables for BudgetProDROP 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 embeddedSQL statements in the applicati<strong>on</strong> code. But this is far from your <strong>on</strong>ly choice.It is possible to design a “persistence framework,” such that all classes thatinherit from a persistence base class or implement a persistence interface andfollow certain naming c<strong>on</strong>venti<strong>on</strong>s for member data can be automaticallybacked by persistent storage. Java’s ability to introspect, that is, to look at thenames and structures of a class dynamically at runtime, allow <strong>on</strong>e to write suchan automatic persistence framework. Several such libraries already exist, includingboth commercial and Open Source opti<strong>on</strong>s. This being an Open Sourcebook, we’ll call you attenti<strong>on</strong> to the Open Source choices: 33. Have we tried all of these? Yeah. Sure. Why not? Of course we haven’t. D<strong>on</strong>’t read endorsementinto this or any of our “here are some choices” lists. These are also not presented in anyparticular order. We tell you they exist. It is up to you to evaluate their suitability for yourpurposes.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!