Problem
In general, the hibernate entities (domains) are set to use database sequence as Id generator.
In such a case, for every insert ...
For further actions, you may consider blocking this person and/or reporting abuse
Will 'pooled' optimizer strategy work with MySql database and Hibernate (Spring-Data-Jpa) as ORM
Yes it will work.
[Edit] Sorry, it will not work.
Hi,
I am using spring batch and inserting records in batch. I have set 1000 as allocation size and seq increment value. However sometimes when job fails and restarts,
I am getting unique constraint violation when i am using pooled optimizer. Could you please let me know the cause and solution ?
Also is there any way we can clear the in memory sequence values whenever job fails or in any condition ?
Thanks.
May be these could help you:
youtube.com/watch?v=2LH_miNH7h0
blog.jooq.org/2013/12/09/how-to-in...
stackoverflow.com/questions/276978...
why " 'pooled' optimizer strategy work with MySql database and Hibernate " does not work?
I tried this example and it worked below are the versions that i have used:
Session Metrics {
1720780 nanoseconds spent acquiring 2 JDBC connections;
15750 nanoseconds spent releasing 1 JDBC connections;
110738 nanoseconds spent preparing 3 JDBC statements;
1044388 nanoseconds spent executing 2 JDBC statements;
13444485 nanoseconds spent executing 1 JDBC batches;
0 nanoseconds spent performing 0 L2C puts;
0 nanoseconds spent performing 0 L2C hits;
0 nanoseconds spent performing 0 L2C misses;
44990162 nanoseconds spent executing 1 flushes (flushing a total of 50 entities and 0 collections);
0 nanoseconds spent executing 0 partial-flushes (flushing a total of 0 entities and 0 collections)
}
This looks line Table generator but i use the generator code from this post.
Hibernate is created hibernate_sequence table when i used sequence generator. Since mysql doesnt support sequence generator hibernate fall back to table generator due to which i was able to run example mentioned in the post.
Thanks for pointing it out. My bad, I didn't think of that.
You are right, it will not work. However, we can use IDENTITY and handle the batch inserts via jOOQ instead of Hibernate.