//mobile and embedded /
Oracle Berkeley DB Java Edition’s
Java API
TED NE WARD
Learn how the Java API for Oracle Berkeley DB Java Edition works.
JAVA IN ACTION
PHOTOGRAPH BY
PHIL SALTONSTALL
In the summer of 2005, while at a Microsoft conference, I
was asked what I thought of the
then-current technical fad, the
object-relational mapping (ORM)
tool. My response, predictably, got
some attention. I said that ORM is
the Vietnam of computer science.
At the time, I was definitely
“swimming upstream” because
“everybody” knew that the only
reasonable place to store data was
in a relational database, preferably a big one. In fact, the bigger,
the better—who wouldn’t want
more RAM, more disk space,
faster I/O, the works.
I argued, in part, that no mat-
ter how much we try, the different
“shapes” of the data—for exam-
ple, our graphs of objects and the
database’s rectangular tables—
create mismatches that are very
hard to eliminate, no matter how
sophisticated the tooling or librar-
ies. It’s particularly gruesome
to try to shove a hierarchy into a
table, for example, and trying to
capture a cyclic graph (such as
the one we see with the Facebook
platform) is nearly impossible.
Not that it can’t be done, but
when a subject requires an entire
book on just that one idea (Joe
Celko’s Trees and Hierarchies in
SQL for Smarties), there’s prob-
ably more work there than we’d
really like.
Using Oracle
Berkeley DB Java
Edition is quite
straightforward, partly
due to its surface
similarities to the
relational model, but
make no mistake—
attempts to use it as
such are likely to result
in serious failure.
As the NoSQL
movement gained
prominence,
developers realized
that perhaps
the relational
database isn’t
the only place
data needs to go.
Essentials
Unlike many database
APIs, the Java API for
Oracle Berkeley DB
Java Edition has two “levels.”
The first level, the base API, is a
low-level read/write set of opera-
tions that essentially thinks of
everything in terms of key/value
pairs, where the values are byte
arrays that Java developers know
how to create and parse, typically
using either standard Java serial-
ization or Oracle Berkeley DB Java
Edition’s own “bind” APIs.
As a general rule, unless you
want or need to operate at this
level of storage (and
for the most part, the
only reason you would
want to do that is to be
able to support dupli-
cate primary keys), it’s
useful only to know
that such accessibility
is available and move
on to the second API.
ABOUT US