Have you implemented OpenMRS? Please participate in the Implementation Site Survey. If you already have, thank you!
A hibernate mapping bi-directionally maps data from MySQL to Java and vice versa. A mapping might look something like this:
Creating an Object
|package||The location of the java class file being mapped|
|class name||The name of the java class being mapped|
|table||The name of the MySQL table being mapped|
|id||The id of the object|
|the MySQL field relating to the defined variable|
Common MySQL to Java translations
|name||The field defined by your java object|
|column||The field defined by your MySQL table|
|type||The data type of the data, integer, string, ect.|
|not-null||When set to be true the field is required when defining the object|
Common MySQL relations
Relations are commonly translated from MySQL foreign keys to Java classes.
|Fields||Java class definition|
|one-to-one||Your object relates to one of the defined objects||Defined as the related object type|
|many-to-one||Multiple of your object can relate to one of another object||Defined as a list of the related object type|
|Your object can contain multiple of the related objects||Defined as a list of the related object type|
|class||Similar to type, this field defines the object type that is being related|
Note: These associations are defined and created by your liquibase.xml file first, so you will need to reference those to determine the relation type.
There should be a mapping file for each entity that your module/hibernate is maintaining. If you have two objects, then make two classes called FormEntryQueue and FormEntryArchive, then make FormEntryQueue.hbm.xml and FormEntryArchive.hbm.xml and put them both in the resources folder.
Deploying your mapping
If you are using the maven layout, this element is automatically populated with all found *.hbm.xml files.
If using the pre-maven layout (ant) then you will need to list off each of your hbm.xml files in that element.
If you are building using ant add the following lines to the bottom of your config.xml