I am an experienced Java and SQL developer considering Clojure for my next project. I have spent some time studying the basics but still struggling to understand the idiomatic way to painlessly handle interactions with a relational database with regards to updates.
Most of the threads I have read focus on the query side which for me is actually not a problem since I am very comfortable with SQL and consider jdbc.next to be more than adequate for my querying needs (maybe augmented by Toucan 'hydration' support if required).
My main concern is how to handle persistence e.g. how to automatically persist a modified (nested) map(?) back to the database without the need to keep track of state myself.
As a side note, I have enough experience with both Hibernate itself and JPA and still feel they are too rigid and verbose.
The tool I consider ideal on this regard is https://www.sqlalchemy.org/ which I have previously used via jython with a great sense of satisfaction.
Thanks a lot for all your input.
Update based on some comments/questions below:
To - hopefully - set the context more clearly, suppose a web application shopping cart scenario: A new customer checks out. An insert needs to be performed for the customer, possibly another for the shipping address, another for the order and these need to be synchronized in a way that referential integrity is preserved. Doing all the steps manually is of course an option but the more involved the scenario the more complex handling becomes. My database is relational.
Second update
To clear up my question further, my problem is not how to issue the 'insert/update/delete' statements but more of keeping track of which statements must be issued according to the current state of things.
I would expect the 'ORM' layer to track which of my 'data' are new, which have been modified, deleted etc. and execute the above snippet automatically in a consistent way similar to Hibernate's entity manager (please have a look at the below link https://www.sitepoint.com/hibernate-introduction-persisting-java-objects/ in section "Performing CRUD Operations on Entities" for an example of the intended functionality).
Alternatively I would like to be able to identify what happened on each 'piece' of my data (object graph in hibernate parlance) and then execute the snippet you shared by traversing each element, 'querying' its state/status and inferring the correct statement to send back to the database.
From my understanding of the language so far this functionality is native(?) to clojure data structures - but I have not been able to put my finger on it yet.