Restricción Única Sobre Varias Columnas
Estoy usando SEAM 2/Hibernate junto con la base de datos PostgreSQL 9. Tengo la siguiente tabla
Active Band
===========
active_band_id serial
active_band_user text
active_band_date timestamp
active_band_process integer
Me gustaría agregar una restricción que asegure que cada nueva entrada tenga una combinación única de active_band_user y active_band_date.
Potencialmente podría haber muchos insertos intentados por segundo, así que necesito que esto sea lo más eficiente posible, ¿hay una anotación de COSTURA / hibernación que pueda usar en la asignación de entidades?
Gracias de antemano
30
1 answers
No hay una anotación de hibernación que verifique la unicidad antes de insertar/actualizar. Pero hay una anotación que generará tal restricción a la base de datos si se usa la creación automática de la base de datos:
@Table(
name="ACTIVE_BAND",
uniqueConstraints=
@UniqueConstraint(columnNames={"active_band_user", "active_band_date"})
)
62
Author: Mikko Maunu,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-08-14 16:24:27
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-08-14 16:24:27