...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="org.openmrs.module.YourJavaClass"> <class name="YourJavaClass" table="your_mysql_table"> <id name="id" column="your_mysql_table_id"> <generator class="native"/> </id> <property name="sampleInteger" type="java.lang.Integer" column="simple_integer"/> <property name="sampleString" type="java.lang.String" column="sample_string" length="255"/> <property name="uuid" type="java.lang.String" column="uuid" length="38" not-null="true" unique="true"/> <property name="dateCreated" type="java.util.Date" column="date_created" length="19" not-null="true"/> <many-to-one name="patient" class="org.openmrs.Patient" column="author_id" not-null="true"/> <one-to-one name="encounter" class="org.openmrs.Encounter" column="encounter_id" not-null="true"/> <one-to-many name = "provider" class="org.openmrs.Provider" column="provider_id" not-null="true"/> </class> </hibernate-mapping> |
...
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
The config.xml file has an element called "mappingFiles" that lists off all hbm files that need to be loaded. If If you are using the maven layout, this element is automatically populated with all found *.hbm.xml files. If
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 you are building using ant add the following lines to the bottom of your config.xml
...