Start here. This is the direct spoken answer to practice first.
Overview
A loop around save is not automatically a batch; SQL batching and persistence-context lifetime both need design.
I enable an appropriate Hibernate JDBC batch size, use an identifier strategy that permits batching, and process input in bounded chunks. Within a chunk I persist or update entities, then flush and clear the persistence context periodically so managed instances and snapshots do not grow without limit. I inspect the SQL or statistics to confirm statements are actually batched. The transaction size balances atomicity, lock duration, memory, and restart cost.