2

I am using EclipseLink for a small project to record user activities. I have a class that captures details about the activity and I am using the table generator strategy to generate the primary key ids for that class.

The issue I am facing is that EclipseLink (I will call it EL) is assigning primary keys at an increment of 50 which I understand is the default value for the allocationSize. This is within the same JVM cycle (i.e., no reboot).

I understood that the allocationSize is used for the number of IDs EL would pre-allocate in memory. I would like to use this functionality, but EL doesn't seem to be working like that.

Only when I change the allocationSize to 1 do I get EL to generate Primary Keys sequentially.

Any help would be greatly appreciated...

I am using EclipseLink 2.3.0.

vgoff
  • 10,980
  • 3
  • 38
  • 56
  • Can you explain what isn't working a bit more? Setting it to 1 tells EclipsLink it needs to go to the table for each sequence. How are you trying to use it? – Chris Nov 19 '12 at 13:16
  • Even with an allocation size of 50, the ids will still be assigned more or less sequentially unless you close your EntityManagerFactory. Include your code and persistence.xml – James Nov 19 '12 at 15:36
  • Thanks everyone for your help. I have solved my problem. I was manually managing the lifecycle of the `EntityManager` and the transactions as well. I changed my code to have the `EntityManager` injected into my EJB and let the container take care of the transactions. I have set the allocationSize to 1000 and getting the desired results. Once again, thanks vels4j, Chris, and James for your help. – westendraider Nov 21 '12 at 02:23
  • @westendraider Could you put your solution into an answer for this question and mark it resolved? It makes it easier to hunt down genuinely open questions. – Mark Robinson Jan 05 '13 at 06:07

1 Answers1

0

Thanks everyone for your help.

I have solved my problem. I was manually managing the lifecycle of the EntityManager and the transactions as well. I changed my code to have the EntityManager injected into my EJB and let the container take care of the transactions. I have set the allocationSize to 1000 and getting the desired results. Once again, thanks vels4j, Chris, and James for your help