Helma logo
helma.org » Home > docs > guide > introductions > Database mapping

Database mapping

Helma allows you to map your HopObjects to relational database tables instead of persisting them in the application's embedded XML database.

The list of available database connections is defined inside the file ./db.properties in Helma's home directory or for application specific configurations in a db.properties file inside an application's code repository.

myDataSource.url = jdbc:mysql://db.domain.com/space
myDataSource.driver = org.gjt.mm.mysql.Driver
myDataSource.user = username
myDataSource.password = xyz
In order to add the specified JDBC driver to the classpath, place it in the ./lib/ext/ directory. Depending on the database system you are using, you may want to download an appropriate JDBC driver, for example a driver for MySQL.

Using the SQLshell from within your application, you may at any time explore your database and issue SQL statements. The SQLshell also allows you to map your database tables to properties of your application's prototypes as desired. A simple configuration for your object/relational mappings might look as follows:
_db         = myDataSource
_table      = PERSON
_id         = ID

firstname   = FIRSTNAME
lastname    = LASTNAME
email       = EMAIL
createtime  = CREATETIME
modifytime  = MODIFYTIME
These configurations would be placed in a type.properties file inside the corresponding prototype directory, for example in ./apps/addressbook/Person/type.properties, when following the "addressbook" tutorial.

To learn how Helma's relational database mapping is put to work and how it relates and integrates with the other central aspects of the framework, follow the tutorial and build the full "addressbook" application.

More information about the object/relational mapping of HopObject properties:
/docs/guide/properties/db.properties/
/docs/guide/mapping/
/docs/tutorial/wiring/


Up: Introductions
Previous: Prototypes Next: Java packages

... comment


Page last modified on 2005-12-19 14:55 by czv

 
jdl, Thursday, 23. February 2006, 20:49
A bit more background on persistence...
It seems a couple background facts about persistence should be mentioned here.
Perhaps obvious to old hands, but they should be documented explicitly.
(I'm just learning this myself, so hope this is correct...):

- How you choose between the two persistence layers:
Persistence is via either the embedded XML store or the RDMS ORM layer.
You choose which one by whether or not your create type.properties.

- Which objects are persisted?
HopObjects can be transient or persisted. As I understand it: You can create
transient HopObjects with "new" whenever you like, and this can be useful.
An object becomes persistent if it is becomes a property or a member of the child
collection of a object that's already persistent. Presumably, all persistent objects
then trace back up to root, the only initially persistent object.

This latter fact could be discussed more in the docs. (It seems there is one
sentence about it in the middle of the "conceptual overview", but not in the
introductions or tutorial.) Also, a paragraph or two on common uses of
transient objects (for instance, what about wrapping Java objects with
HopObjects so they can be skinned?) would be helpful.

... link  


... comment