-
Notifications
You must be signed in to change notification settings - Fork 0
relationships
Satish Sharma edited this page Jul 10, 2018
·
1 revision
In this section you will learn how to create the relationships between entities in Magic-Code format.
__Note: !!! caution
These elements may vary according to the framework and tool selected for project. Currently these are specific to Spring Boot Data JPA and related frameworks.
For more deeper dive of the associations please visit [hibernate documentation](https://docs.jboss.org/hibernate/orm/3.6/reference/en-US/html/associations.html)
**Do not use blank spaces and special characters in any of values for these element using which may cause failure in application generation.**
!!! note "" Possible Value : NA
This is the parent element for defining entites and pojos in ***Magic-Compose***. You will always define your entities or DTO/POJO whithin this tag.
!!! note "" Possible Value : ONETOONE/ONETOMANY/MANYTOONE/MANYTOMANY
The type of ***JPA Association*** you want to have between the entities.
!!! note "" Possible Value : true/false
Set this value to true if you want this relationship definition to be bi-directional
!!! note "" **Possible Value : Any valid defined entity type in entities section **
This field defines which one of the two entities owns the relationship.
For example
Consider a scenario where a ***Student*** entity can have multiple ***Address***.
Here ***Student*** is going to be ***"parent"*** and ***Address*** is going to be ***"child"***
!!! note "" Possible Value : any valid java identifier
The name of the relationship given in parent/owning class.
!!! danger "Added in Entities by framework" Possible Value : any valid java identifier
The name of the field to be used while performing joins. **Do not add this column while defining your entities, as this shall be added by the ***Magic-Code*** framework.**
!!! note "" **Possible Value : Any valid defined entity type in entities section **
This field defines which one of the two entities play's the role of child in the association mapping.
For example
Consider a scenario where a ***Student*** entity can have multiple ***Address***.
Here ***Student*** is going to be ***"parent"*** and ***Address*** is going to be ***"child"***.
!!! note "" Possible Value : any valid java identifier
The name of the relationship given in child class.
!!! danger "Added in Entities by framework" Possible Value : any valid java identifier
The name of the field to be used while performing joins. **Do not add this column while defining your entities, as this shall be added by the ***Magic-Code*** framework.**
"relationships": [
{
"relationType": "ONETOMANY",
"bidirectional": true,
"parent": "Student",
"parentRelationshipName": "address",
"parentJoinColumn": "address_id",
"child": "Address",
"childRelationshipName": "student",
"childJoinColumn": "student_id1"
},
{
"relationType": "ONETOONE",
"bidirectional": true,
"parent": "Student",
"parentRelationshipName": "details",
"parentJoinColumn": "details_id",
"child": "StudentDetails",
"childRelationshipName": "student",
"childJoinColumn": "student_id2"
}
]
