Reputation: 138
I have a large set od data say(7000) of data that needs to to inserted in three tables say table A,B,C and all having an autogenerated column @id.
Now Table B is dependent on A's auto generated @id .
During batch insert I want to set a logic so that after a certain threshold the records will be persistent/commit to the database and I am using hibernate transaction. Is it possible to get the dependent auto generated id from A's table before it is been persisted /commit.
Thanks for the reply in advance
Upvotes: 1
Views: 466
Reputation: 5095
Auto-generated IDs in databases that do not support explicit sequences (such as MySQL) are retrieved upon insertion. There is no other mechanism for it, unless you simulate the generation on the Java side and set them there. That, however will not work well if your application ever runs with more than one instance.
Upvotes: 2