Looking for help to implement transaction management in loopback4. Using ms-sql database and loopback-connector-mssql as a connector.
i am extending repository with DefaultTransactionalRepository.
below is the code i am writing inside controller.
1. const addressTransaction = await this.addressRepo.beginTransaction();
2. const address = await this.addressRepo.create(addressObj);
3. addressTransaction.rollback()
Issue is, record which i created at line 2 is not getting reverted after line no 3, there is no error as well. also i am getting addressTransaction object back at line no 1. above 3lines are just an example. moto is i want to revert back data that inserted at line no2.
If i execute below code into DB its working perfectly fine. record is getting roll back.
BEGIN TRANSACTION
INSERT into addresses(ADDRESS_CITY,ADDRESS_STATE) values('123','1234')
ROLLBACK
but some how connector is not working properly.
i checked with DBA, look like we are not setting implicit_transactions on with above transaction. does anyone know how to set implicit_transactions on.
Any issue with the way i am implementing the transaction? kindly help