I'm having trouble getting Hibernate to perform a bulk insert on MySQL.
I'm using Hibernate 3.3 and MySQL 5.1
At a high level, this is what's happening:
@Transactional
public Set<Long> doUpdate(Project project, IRepository externalSource) {
List<IEntity> entities = externalSource.loadEntites();
buildEntities(entities, project);
persistEntities(project);
}
public void persistEntities(Project project) {
projectDAO.update(project);
}
This results in n log entries (1 for every row) as follows:
Hibernate: insert into ProjectEntity (name, parent_id, path, project_id, state, type) values (?, ?, ?, ?, ?, ?)
I'd like to see this get batched, so the update is more performant. It's possible that this routine could result in tens-of-thousands of rows generated, and a db trip per row is a killer.
Why isn't this getting batched? (It's my understanding that batch inserts are supposed to be default where appropriate by hibernate).