Update multiple related tables using Spring Data Rest -
i have 2 tables employee , address having one-to-one relationship.
create table employee( id bigint primary key not null, emp_name varchar(50) not null, phone_id bigint, deleted boolean not null default false, constraint constraint1 foreign key (phone_id) references phone (id) ) create table phone( id bigint primary key not null, ph_number varchar(20) not null, deleted boolean not null default false, ) i using spring data rest.
q1. want expose single data rest repository method update deleted column both employee , `phone.
something below:
testrepository implements crudrepository{ @query(value="update both table query", native=false) public void updateboth(); } q2. doing possible using spring data rest.
please note: not want use native query, i.e. @query(value="", native="true")
you have find balance between using framework , overusing it.
spring data rest expose repositories http can't solve it.
the proper way here create custom controller , implement functionality want proper transaction management have data integrity need.
Comments
Post a Comment