There is no batch insert operation in vanilla JPA.
Yes, each insert will be performed as part of its own transaction. An attribute @Transactional(without qualifiers) means the distribution level REQUIRED(create a transaction if it does not already exist). Assuming you have:
public class Dao {
@Transactional
public void insert(SomeEntity entity) {
...
}
}
do the following:
public class Batch {
private Dao dao;
@Transactional
public void insert(List<SomeEntity> entities) {
for (SomeEntity entity : entities) {
dao.insert(entity);
}
}
public void setDao(Dao dao) {
this.dao = dao;
}
}
Thus, the entire group of inserts is wrapped in a single transaction. If you are talking about a very large number of inserts, you can split it into groups of 1000, 10000, or everything that works, since a sufficiently large uncommitted transaction can starve from the resource database and, possibly, a failure due to size only.
Note. @Transactional- Spring annotation. See Transaction Management from the Spring Directory.