-
Notifications
You must be signed in to change notification settings - Fork 0
dto_entities
In this section we explain about what are the options using which you can generate a DTO or JPA entites In a mgic-compose json file the parent element for these configurations is entities which can be used to create both the DTO's and the JPA entities. Also the framework will autogenrate the Spring Boot Data JPA repository interfaces for all the db entities.
Note: These elements may vary according to the framework and tool selected for project. Currently these are specific to Spring Boot JPA and related frameworks.
!!! warning 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 POJO/DTO's in ***Magic-Compose***. You will always define your entities or DTO/POJO whitin this tag.
* All the defined entities which have ***dto*** set to ***true*** shall be generated in ***<basePackage>.dto***.
* All the defined entities which have ***dbentity*** set to ***true*** shall be generated in ***<basePackage>.db.entities*** and the JPA repository interfaces for all these entities shall be generated in ***<basePackage>.db.repositories***
!!! note "" Possible Value : Any valid java class name
The name of the class. Magic-Code will generate DTO or JPA entity based on the values of **dto** and **dbentity** field. What if you want to generate both DTO and JPA entity for a entity, you do not need to define two times, you can do that in one go by setting both the values to true.
!!! danger ""
Currently this porperty is not used. This is kept for future use to support composite keys
!!! note "" Possible Value : true/false
Set this to true if you want this entity to be a POJO/DTO
!!! note "" Possible Value : true/false
Set this to true is you want the entity to be a JPA entity object
!!! success "" This is an parent element for all the properties which define the fields of an entity or POJO/DTO
##### **name**
!!! note ""
**Possible Value : any valid java identifier for fields**
Magic-Code will generate the field name using this value.
##### **primaryColumn**
!!! note ""
**Possible Value : true/false**
Set this fields to **true** for defining this column as primary column.
Currently we generate primary column as
**@Id**
**@GeneratedValue(strategy=GenerationType.AUTO)**
##### **datatype**
!!! note ""
**Possible Value : INT/STRING/ARRAY/OBJECT/NUMBER/DOUBLE/DATE/BOOLEAN**
* INT : to declare a field as java **int**
* STRING: to declare as java **String**
* Array: to declare as java **List<ref type>**
* OBJECT: to declare as type of other **object**
* Other : as same valid java type
##### **format**
!!! note ""
**Possible Value : ARRAY**
Set this to ARRAY in case you want the List type. If this is set then **ref** property is mandatory.
##### **ref**
!!! warning "Used only is mentioned cases else not used"
**Possible Value : any defined entity type**
This value of this field could be any defined ***entity*** type and its **only used** below cases
* If the value of ***format*** is defined as ***ARRAY***
* If the value of ***datatype*** is defined as ***OBJECT***
"entities": [
{
"name": "Category",
"dto": true,
"dbentity": false,
"fields": [
{
"name": "id",
"primaryColumn": true,
"datatype": "INT"
},
{
"name": "name",
"primaryColumn": false,
"datatype": "STRING"
}
]
},
{
"name": "User",
"dto": true,
"dbentity": false,
"fields": [
{
"name": "id",
"primaryColumn": true,
"datatype": "INT"
},
{
"name": "username",
"primaryColumn": false,
"datatype": "STRING"
},
{
"name": "firstName",
"primaryColumn": false,
"datatype": "STRING"
},
{
"name": "lastName",
"primaryColumn": false,
"datatype": "STRING"
},
{
"name": "email",
"primaryColumn": false,
"datatype": "STRING"
},
{
"name": "password",
"primaryColumn": false,
"datatype": "STRING"
},
{
"name": "phone",
"primaryColumn": false,
"datatype": "STRING"
},
{
"name": "userStatus",
"primaryColumn": false,
"datatype": "INT"
}
]
},
{
"name": "Pet",
"dto": true,
"dbentity": false,
"fields": [
{
"name": "id",
"primaryColumn": true,
"datatype": "INT"
},
{
"name": "category",
"primaryColumn": false,
"datatype": "OBJECT",
"ref": "Category"
},
{
"name": "name",
"primaryColumn": false,
"datatype": "STRING"
},
{
"name": "photoUrls",
"primaryColumn": false,
"datatype": "ARRAY",
"ref": "string"
},
{
"name": "tags",
"primaryColumn": false,
"datatype": "STRING"
},
{
"name": "status",
"primaryColumn": false,
"datatype": "STRING"
}
]
},
{
"name": "Student",
"idcolumn": "id",
"dto": true,
"dbentity": true,
"fields": [
{
"name": "id",
"primaryColumn": true,
"datatype": "INT",
"format": "INT32"
},
{
"name": "firstName",
"datatype": "STRING"
}
]
},
{
"name": "StudentDetails",
"idcolumn": "id",
"dto": true,
"dbentity": true,
"fields": [
{
"name": "id",
"primaryColumn": true,
"datatype": "INT",
"format": "INT32"
},
{
"name": "MiddleName",
"datatype": "STRING"
},
{
"name": "Email",
"datatype": "STRING"
},
{
"name": "lastName",
"datatype": "STRING"
}
]
},
{
"name": "Address",
"idcolumn": "id",
"dto": true,
"dbentity": true,
"fields": [
{
"name": "id",
"primaryColumn": true,
"datatype": "INT",
"format": "INT32"
},
{
"name": "city",
"datatype": "STRING"
},
{
"name": "state",
"datatype": "STRING"
},
{
"name": "Country",
"datatype": "STRING"
}
]
}
]
