Amrut Prabhu yes got the clarity now.. It's the issue with hibernate.. Actually for bulk inserts.. Before, I was wondering that when I tried inserting rows to mysql id used to be generated by database.
From a database point of view, this is very efficient because the auto-increment columns are highly optimized, and it doesn’t require any additional statements.
This approach has a significant drawback if you use Hibernate. Hibernate requires a primary key value for each managed entity and therefore has to perform the insert statement immediately. This prevents it from using different optimization techniques like JDBC batching.