- • Quickstart
- › Documentation
- • Documentation DevOps
- • Next Steps
- • Spring Boot
- • Spring Data
- • Spring Data MongoDB
- • Spring Security
- • Frontend
- • Multi-Module
Last updated: 2023-03-06
Entity tab - backgrounds
In the Entity tab the database schema for the new Spring Boot application can be created.
The Entity tab with a simple database schema
Initially, there are no entities in a new project. They can be added by clicking on the plus sign. After saving, the future tables are displayed in a UML preview.
When creating or editing an entity, the name can be specified first. This is automatically converted into the correct formatting for the Java class (pascal case "CarPart") and if necessary the table name (snake case "car_part"). If the name is a keyword in the chosen database system, an annotation is added to the table to quote it - e.g.
@Table(name = "\"user\"") in Postgres. If MongoDB is chosen as the database, the entities are created with the
Editing an entity in the Bootify Builder
The option "Add REST Endpoints" automatically generates a Data Transfer Object (DTO), a Service and a Resource class to provide a REST API with simple CRUD operations for the entity. The DTO contains annotations to validate the specified contraints (e.g.
@Size(max = 255)). The option "Add frontend controller" is only available when a frontend has been selected for your application in the General tab. It will add a Controller and required Thymeleaf templates on top. In the Professional plan, additional checkboxes for pagination and a search filter is available and will be applied to both, REST and frontend controllers.
A total of four types are available for the primary key.
Long (default) are generated by the database via a sequence.
UUID is filled by Hibernate's
UUIDGenerator before the first persistence.
String must always be provided by the application or REST endpoint and, as a primary key, can never be updated.
For the other fields, many more simple types are available, e.g.
LocalDate. In addition, Enums and Data Objects created in the Data Objects tab can be selected. Enums are always written to the database as strings, whereas Data Objects are persisted as JSON fields using the
After the first entity has been created, relations can also be added to the database schema. The available types are One-to-One, Many-to-one, One-to-many and Many-to-many. Appropriate JPA annotations are added based on the selected type - check out JPA relationship types with examples for more details. Circular references are possible, but not all of them are allowed to be required - this would make it impossible to persist any values.
Adding a many-to-many relation to our project
If MongoDB is chosen as the database, relations are added to entities with
@DocumentReference. This way MongoDB uses a manual reference internally, while the developer can still directly access the referenced document - more backgrounds here.
Using the SQL Import of the Free plan, the entities and relations can be created directly from a SQL script. The link "Import Schema" in the Entity tab opens a modal into which the script can be copied.
Paste your SQL script to see a preview
The relevant entries from the script are automatically parsed (starting with
CREATE TABLE /
ALTER TABLE). A preview is displayed in the next step, which can then be copied into the project. Existing entities and relations will be overwritten. The imported entities have the REST option disabled at first.
If the application is to be connected to an existing database later, it is recommended to set the DB Generation to None (validate) in the General tab. This will cause Hibernate to compare the entities with the actual database schema when starting the application and throw an exception if necessary. Minor adjustments are usually still needed in order to map the field types without errors.
No registration required