I found, that method
Iterable<S> CrudRepository#save(Iterable<S> entities)
works very slow.
If instead, I take Iterable
myself and create long query like this
INSERT INTO mytable (field1, field2) VALUES
(value1, value2),
(value3, value4),
...
(valueN, valueM);
and execute it against entity manager, it works much faster (by factor of 10 and more).
Can I make Spring-Data itself work the same fast?
For example, are there any options to force Hibernate or any underlying library use such multivalue queries?
I am using SQLite and the class from here: https://stackoverflow.com/a/24233241/258483
May be I can imrpove this class somehow?
UPDATE
I am using identity generation with
@Entity
@Table(name = "variable_values")
public class VariableValue {
@Id
@Column(name="id")
@GeneratedValue(generator="sqlite")
@TableGenerator(name="sqlite", table="sqlite_sequence",
pkColumnName="name", valueColumnName="seq",
pkColumnValue="variable_values")
@Getter
@Setter
private long id;
does this mean I can't benefit from batching?