Skip to content
Siminov Framework edited this page Aug 18, 2015 · 6 revisions

One to Many

One-To-Many relationship is in which each row in the related to table can be related to many rows in the relating table. This effectively save storage as the related record does not need to be stored multiple times in the relating table.

Example: All the customers belonging to a business is stored in a customer table while all the customer invoices are stored in an invoice table. Each customer can have many invoices but each invoice can only be generated for a single customer.

One To Many Syntax:

    <entity-descriptor>

            <relationships>
			
                <relationship>
                    <property name="type">one-to-many</property>
                    <property name="refer">name-of-variable</property>
                    <property name="refer_to">map_to_model_class_name</property>
                    <property name="on_update">cascade/restrict/no_action/set_null/set_default</property>
                    <property name="on_delete">cascade/restrict/no_action/set_null/set_default</property>
                    <property name="load">true/false</property>
                </relationship>		
		    		
            </relationships>		

    </entity-descriptor>