Restorante’s persistence layer is built on a set of JPA entities that map the full lifecycle of restaurant operations — from staff management through to menu composition. Two distinct inheritance strategies are used:Documentation Index
Fetch the complete documentation index at: https://mintlify.com/NicolasMPP/restorante-springboot/llms.txt
Use this file to discover all available pages before exploring further.
JOINED for the Persona hierarchy (each subclass occupies its own table, joined on the primary key) and SINGLE_TABLE for both the Alimento and Empleado hierarchies (all subtypes share one table, distinguished by a discriminator column). This combination keeps staff identity data normalized while keeping food and employee-role queries fast.
Core Entities
Persona
Table:
personasBase class for all people in the system. Uses JOINED inheritance — every subclass stores its own additional columns in a separate table, linked back to personas by primary key.| Field | Type | Constraints |
|---|---|---|
id | Integer | Auto-generated PK |
nombre | String | Not null, max 100 chars |
cedula | String | Not null, unique, 7–20 chars |
telefono | String | Optional, max 20 chars |
correo | String | Optional, max 100 chars |
usuario | String | Optional, max 50 chars |
contrasenia | String | Optional, max 100 chars |
Empleado
Table:
Has a
empleadosExtends Persona via JOINED inheritance (@PrimaryKeyJoinColumn(name = "id")). Uses its own SINGLE_TABLE inheritance for employee subtypes (Chef, Mesero), controlled by the tipo_empleado discriminator column.| Field | Type | Constraints |
|---|---|---|
fechaVinculacion | LocalDate | Hire date |
horaIngreso | LocalDateTime | Start of shift |
horaSalida | LocalDateTime | End of shift |
salario | BigDecimal | Precision 10, scale 2 |
@OneToMany relationship with Receta (mapped by chef field on the recipe side).Chef
Discriminator:
CHEF in tipo_empleadoExtends Empleado. Adds no new columns — its type is distinguished purely by the discriminator value. Chefs are the primary assignees for Receta entities and are looked up by cédula when creating or updating food items.Mesero
Discriminator:
MESERO in tipo_empleadoExtends Empleado. Shares the empleados table with Chef and the base Empleado discriminator value. No additional columns or special API operations beyond standard employee management.Gerente
Table:
gerentesExtends Persona via JOINED inheritance. Stores no extra columns but owns Menu and Despensa entities via @OneToMany relationships (cascaded ALL). Every Menu and Despensa record must reference a Gerente.Cliente
Table:
clientesExtends Persona via JOINED inheritance. Represents a customer — not an employee and carries no salary or scheduling fields. Stores no additional columns beyond those inherited from Persona.Alimento
Table:
alimentosBase food entity. Uses SINGLE_TABLE inheritance with discriminator column tipo_alimento. All food subtypes (PlatoFuerte, Postres, Bebida, Adicionales) are stored in this single table.| Field | Type | Constraints |
|---|---|---|
id | Integer | Auto-generated PK |
nombre | String | Not null, max 100 chars |
precio | BigDecimal | Not null, precision 10 scale 2 |
receta | Receta | ManyToOne, nullable (receta_id FK) |
menus | List<Menu> | ManyToMany inverse side |
Menu
Table:
menuOwned by one Gerente (@ManyToOne, not nullable). Contains many Alimento entries via the menu_alimentos join table. Also carries an optional nombreMenu field (max 100 chars).Despensa
Table:
despensaOwned by one Gerente (@ManyToOne, not nullable). Holds many Ingrediente records via the despensa_ingredientes join table. Provides stock visibility and low-stock querying at the business-logic layer.Receta
Table:
recetasBelongs to one Empleado (the chef who authored it) via @ManyToOne. Uses many Ingrediente records via the receta_ingredientes join table.| Field | Type | Constraints |
|---|---|---|
id | Integer | Auto-generated PK |
nombreReceta | String | Not null, max 100 chars |
descripcionProceso | String | TEXT column |
Ingrediente
Table:
ingredientesRepresents a single ingredient with a stock counter. Participates in two independent many-to-many relationships: with Receta (which recipes use this ingredient) and with Despensa (which pantries stock it).| Field | Type | Constraints |
|---|---|---|
descripcion | String | Not null, max 100 chars |
cantidadStock | Integer | Not null, ≥ 0 |
Entity Relationship Overview
The following describes how entities connect across the full restaurant workflow:- A
Gerenteowns one or moreMenuinstances and one or moreDespensainstances (both via@OneToManywith cascadeALL). - Each
Menuholds manyAlimentoitems, linked through themenu_alimentosjoin table. - Each
Alimentooptionally references oneReceta(thereceta_idFK is nullable, so drinks and desserts without preparation steps can have a null recipe). - Each
Recetabelongs to oneEmpleado(typically aChef) and uses manyIngredienterecords, linked throughreceta_ingredientes. - Each
Despensastores manyIngredienterecords, linked throughdespensa_ingredientes. Ingredients are therefore shared data — the sameIngredienterow may appear in both a recipe and the pantry.
Join Tables
| Join Table | Owning Entity | FK Column | Inverse FK Column |
|---|---|---|---|
menu_alimentos | Menu | menu_id | alimento_id |
despensa_ingredientes | Despensa | despensa_id | ingrediente_id |
receta_ingredientes | Receta | receta_id | ingrediente_id |
@ManyToMany relationship. The inverse sides on Alimento, Despensa, and Ingrediente use mappedBy and carry @JsonIgnore to prevent serialization cycles.
Inheritance Strategies
- Alimento — SINGLE_TABLE
- Empleado — SINGLE_TABLE
- Persona — JOINED
All food types share the
None of the subtypes add extra columns — the
alimentos table. The tipo_alimento string column acts as the discriminator.| Discriminator Value | Java Class |
|---|---|
GENERAL | Alimento (base) |
PLATO_FUERTE | PlatoFuerte |
POSTRE | Postres |
BEBIDA | Bebida |
ADICIONAL | Adicionales |
tipo_alimento value is the sole differentiator. This makes polymorphic queries across all food types a single-table scan.