site creation software

Transaction wrapper

More operations one transaction

If you want just to put many operations into one transaction, a wrapper would be the best solution to do this.

Just put whatever you want into the body:


        //Wrap all operation into single transaction
        db.wrapTransaction(transaction -> { 
                    //Insert entity 
                    var category = new Category() 
                            .setLastUpdate(toCurrentTimestamp()) 
                            .setName("test") 
                            .insert(transaction);

                    //Update entity
                    category.setLastUpdate(toCurrentTimestamp()) 
                            .update(transaction,                                     tabCategory.colLastUpdate()); 

                    //Delete entity
                    category.delete(transaction);
                    return null;
                }
        );




© Copyright 2020 Elephant Software Klaudiusz Wojtkowiak 
e-mail: contact@daobab.io