Closed jnizet closed 9 years ago
This allows repeating the same row several times. It's useful to populate the database with a large amount of values, using value generators. We could already do that with a simple for loop, but the syntax is prettier:
Insert.into("tag") .withGeneratedValue("id", ValueGenerators.sequence().startingAt(1L)) .withGeneratedValue("name", ValueGenerators.stringSequence("tag-").startingAt(1L)) .columns("description") .repeatingValues("fake description").times(1000) .build();
Note that we can also pass a Map instead of a vararg for the values. Also note that name/value rows built with a row builder can also be repeated:
Insert.into("tag") .withGeneratedValue("id", ValueGenerators.sequence().startingAt(1L)) .withGeneratedValue("name", ValueGenerators.stringSequence("tag-").startingAt(1L)) .row() .column("description", "fake description") .times(1000) .build();
The new API repeatingValues() is not documented as exemple in Insert javadoc.
repeatingValues()
Insert
Besides my (uneducated) comments: :+1:!
This allows repeating the same row several times. It's useful to populate the database with a large amount of values, using value generators. We could already do that with a simple for loop, but the syntax is prettier:
Note that we can also pass a Map instead of a vararg for the values. Also note that name/value rows built with a row builder can also be repeated: