Hibernate issuing individual insert statements, even though batch insert is enabled

But what I noticed is, I see individual insert statements 500 times, when flush is called. Is this expected behavior when hibernate.jdbc.batch_size is set?

If you are logging SQL statements with Hibernate, you cannot tell if batching is used.

You need to use a tool like datasource-proxy or p6spy to see that JDBC batching is actually used. Check out this article for more details.

Also, does Hibernate provide any feature to issue an insert multi rows if Oracle database is used? I read, PostgreSQL supported with a setting on JDBC URL, but can this be achieved if Oracle is used instead, without using NativeQuery

PostgreSQL supports multi-row inserts via the reWriteBatchedInserts configuration property. However, that’s needed because, although you’re using a single database roundtrip, PostgreSQL processes each statement individually.

Oracle might not require multi-row inserts, so just make sure you are using SEQUENCE identifiers as IDENTITY generators disable batched inserts as explained in this article.

More, the batch processing example can be optimized too. Instead of just clear-and-flush, you want to commit the DB transaction from time to time to avoid a long-running transaction:

for (int i = 0; i < entityCount; i++) {
	if (i > 0 && i % batchSize == 0) {
		entityTransaction.commit();
		entityTransaction.begin();

		entityManager.clear();
	}

	Post post = new Post(
		String.format("Post %d", i + 1)
	);
	 
	entityManager.persist(post);
}

Check out this article if you want to know the best way to do batch processing with JPA and Hibernate.