Entity (attribute of property)

From JRapid

Jump to: navigation, search

entity is an attribute of property.



The entity attribute of a property is used to establish relationships between entities. It may be used in conjunction with the collection and embedded attributes to establish different types of relationships between entities.

If the property only specifies the entity attribute, a relationship to the target entity (n-1) is created. Keep in mind that if the target entity may hold a large number of records, the use of the size entity attribute is recommended.

When used with the collection attribute, entity properties allow you to create one-to-many and many-to-many relationships between entities.

The embedded attribute modifies not only the visual representation of the relationship on the generated form, but the type of relationship, allowing the developer to force an entity to act as a weak entity.


   name = NAME
   label = LABEL
   entity = ENTITY


This example shows how the entity attribute may be used.

 <entity label="Student" menu="Menu" name="Student">
        <property display="primary" label="First Name" name="firstName"/>
        <property display="primary" label="Last Name" name="lastName"/>
        <property label="Date of birth" name="dateOfBirth" type="date" widget="jdatepicker"/>

    <entity label="Teacher" menu="Menu" name="Teacher">
        <property display="primary" label="First Name" name="firstName"/>
        <property display="primary" label="Last Name" name="lastName"/>

    <entity label="Subject" menu="Menu" name="Subject">
        <property display="primary" label="Name" name="name"/>
        <property entity="Teacher" label="Teacher" name="teacher"/>
        <property collection="set" entity="Student" label="Students" name="students"/>

The Subject entity defines a teacher property of entity-type Teacher. This creates a one-to-many relationship between the Subject and Teacher entities.

A property named students of entity-type Student is defined in the Subject entity too, but this one specifies the collection attribute as well, creating a many-to-many relationship between the two entities.

The resulting form for the Subject entity looks like this. Notice the default widgets created for each type of relationship. An HTML select for the single entity-type and a select multiple for the entity collection property.

Entity attribute example

See also

Personal tools