I'm using Java with Hibernate. I want to:
- Save my data to the database
- Run sql to verify the result
- If the result is valid, then commit, otherwise rollback
So, is it possible to save the result to the database without commit, so that I can use sql / hql to verify data and rollback if needed?
My actual scenario is quite complicated, the simplified version is:
- PERSON joins PERSON_CAR joins CAR joins CAR_SEAT joins SEAT
- Make changes and commit everything
- If any PERSON has more than 10 SEATs, I want to show errors
If I could save everything to the database first, then I can write SQL with GROUP BY and HAVING statement to aggregate the data and only return the ones that exceed.