org.pojava.persistence.sql.package.html Maven / Gradle / Ivy
Show all versions of persistence Show documentation
The sql package contains classes for providing ORM (Object Relational
Model) functionality to POJava. A bean or POJO is mapped to a table or view in
a database using a TableMap. Each field in that mapping is specified in
a FieldMap. Finally, the transformations that occur in adapting field data
from the Database to the POJO and back are managed by AdaptorMaps.
There is a DataSourceMetadata object for capturing MetaData about a
database, and there is a DatabaseCache for quick access to a variety of
data objects gathered.
There are also objects for coordinating transactions between multiple
Connection objects. Collectively, these objects provide a very smooth
and minimalistic means of handling the vast majority of database
interactions.
Here's a brief (if impractical) example:
DistributedTransaction trans=new DistributedTransaction();
List widgets=WidgetDao.listByQuery(trans, new WidgetQuery().forColor("purple"));
for (Iterator it=widgets.iterator(); it.hasNext();) {
Widget widget=(Widget) it.next();
Woozle woozle=new Woozle(widget.getId(), widget.getGizzard());
WoozleDao.updateInsert(trans, woozle);
}
trans.commit();