SiCom uses a MySQL 8 database namedDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/dinogamer089/SiCom/llms.txt
Use this file to discover all available pages before exploring further.
sicom as its sole persistence store. Hibernate 6 manages the object-relational mapping but — because hbm2ddl.auto is set to validate — all tables must exist before the application starts. This page walks through schema creation, persistence configuration, and the one migration script that must be applied to existing installations.
Step 1 — Create the Schema
Connect to your MySQL 8 server as a user withCREATE privileges and execute:
utf8mb4 is important: article descriptions, client names, and comments may contain non-BMP Unicode characters (emoji, accented letters) that utf8 (3-byte) would truncate.
After creating the database, create a dedicated application user and grant the minimum necessary permissions:
Step 2 — Configure persistence.xml
The persistence unit is defined inpersistencia/src/main/resources/META-INF/persistence.xml. Update the JDBC URL, username, and password to match your environment before building the project.
persistencePU is hard-coded in the ServiceLocator class used by all DAO and Facade beans. Do not rename it without also updating those references.
Tables Managed by Hibernate
Becausehbm2ddl.auto=validate is set, Hibernate only checks that the schema matches the entity mappings — it never creates or alters tables automatically. All twelve tables below must already exist when the application context initialises:
| Table | Entity class |
|---|---|
administrador | Administrador |
empleado | Empleado |
cliente | Cliente |
articulo | Articulo |
imagen | Imagen |
renta | Renta |
detallerenta | Detallerenta |
combinacion_mesa | CombinacionMesa |
comentario | Comentario |
stock_diario | StockDiario |
stock_reservado_diario | StockReservadoDiario |
movimiento_almacen | MovimientoAlmacen |
Step 3 — Run the Stock-Reservation Migration
sql/migration_fecha_inicio.sql is an idempotent migration script that must be applied to any installation that predates the stock-reservation feature. It is safe to run multiple times — every step checks INFORMATION_SCHEMA before making a change.
What the Script Does
The migration is split into two parts: Part 1 — Addfecha_inicio to the renta table
- Adds the column
fecha_inicio DATE NULLafter the existingfechacolumn if it does not already exist. - Back-fills
fecha_iniciofromfechafor any rows where it isNULL. - Alters the column to
NOT NULLonce all rows have a value. - Creates the index
idx_renta_fecha_inicioonrenta(fecha_inicio)if it does not exist.
cambiar_estado_renta stored procedure
The new version of the procedure understands the full rental date range [fecha_inicio, fecha] and handles stock-reservation bookkeeping atomically:
- Approving / confirming a rental (
SOLICITADA→AprobadaorConfirmado) inserts or increments rows instock_reservado_diariofor every article across every day in the rental window. - Cancelling / finalising a rental decrements those rows and deletes any that reach zero, freeing stock for future bookings.
Stored Procedure Signature
Running the Migration
Opensql/migration_fecha_inicio.sql in MySQL Workbench (or any MySQL client) and execute the entire file against the sicom database:
SELECT statements against INFORMATION_SCHEMA that each return exactly one row when the migration completed successfully.
After applying the migration, restart the application server so Hibernate re-validates the updated schema.