I am working on a Spring-MVC application where I am using PostgreSQL database with hibernate. I realize that Hibernate has its own trigger but using them involves a lot of overhead. For this reason, I would like to use a PostgreSQL trigger.
Have a look at the data-model pasted below.
Question :What should it do? Answer : After database gets updated(CRUD operations), there is a integer-column(noteorder) which defines ordering of the data. I would like to reset that and start it to 1 and increment until end of row.
There is a catch too: :-( Can I pass parameters like do use triggers when certain conditions like sectionid or canvasid is fulfilled?
Is this possible or do I have to Hibernate triggers. Kindly let me know, any ideas, link would be nice. If any question, please leave a comment. Thank you.
Below is the data-model :
CREATE TABLE note
(
noteid integer NOT NULL,
sectionid integer,
canvasid integer,
text character varying,
notecolor character varying,
noteheadline character varying,
id integer NOT NULL,
canvasname character varying,
noteorder integer,
CONSTRAINT noteid PRIMARY KEY (noteid),
CONSTRAINT user_note_fk FOREIGN KEY (id)
REFERENCES person (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
);