Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsIs it possible to run a @TableGenerator in a separate transaction?
https://www.eclipse.org/forums/index.php/mv/msg/167551/531363/#msg_531363
@TableGenerator and the "strategy = GenerationType" to generate ID's. Periodically, I have multiple ID generators for various parts
of the system and periodically I run into a deadlock where one transaction has a lock on one ID generator table row and is waiting
for another one and another transaction has a lock on the other ID generator table row and is waiting for the first. This only
occurs when the generator runs out of pre-allocated ID's and has to update the generator row with the next allocated sequence.
Since I don't really care about ID's not being wasted or holes in the sequence, I was wondering if it is possible to run the ID
allocation in a separate transaction so this deadlock cannot happen?
I supposed I could use just one ID generator table but I think I will still run into issues if I have separate generator rows for
each type of ID that could be assigned.
Any help will be greatly appreciated.
Brett Bergquist]]>Brett Bergquist2010-05-04T15:37:07-00:00Re: Is it possible to run a @TableGenerator in a separate transaction?
https://www.eclipse.org/forums/index.php/mv/msg/167551/531959/#msg_531959
You need to enable a sequence connection pool,
You can also configure the number of connections, data-source, etc. It must use a non-JTA data source to allow accessing ids outside of the transaction context.
Also if you use SEQUENCE id generation it will not have this issue.
]]>James Sutherland2010-05-06T15:22:41-00:00Re: Is it possible to run a @TableGenerator in a separate transaction?
https://www.eclipse.org/forums/index.php/mv/msg/167551/532029/#msg_532029
Derby has an issue with concurrent inserts with IDENTITY columns:
Derby does not yet support SEQUENCE ID generation.
So I decided to switch over to TABLE ID generation and ran into this problem. I researched and found out about the sequence pool,
but it appears that this is available after 1.1.3. I cannot move to 1.2 or 2.0.2 because my environment is using Glassfish v2.1.x
So I was stuck.
I took a look at the source changes between 2.0.2 and 1.1.3 for this support and I built a hard coded session customizer that
enables the sequence connection pool and using a non-JTA data source. I think I got that right in that in Glassfish, I created a
new database connection pool and set the "Non Transactional Connections" capability. So my hard coded session customizer looks like:
public class CanogaEclipseLinkSessionCustomizer implements SessionCustomizer {
and this appears to be working with my testing even with Eclipslink 1.1.3. Is this all that I need to do besides number of
connections, etc.
Thanks in advance for the help.
Brett
James wrote:
> I assume you are using TABLE id generation.
>
> You need to enable a sequence connection pool,
>
> "eclipselink.jdbc.sequence-connection-pool"="true"
>
> You can also configure the number of connections, data-source, etc. It
> must use a non-JTA data source to allow accessing ids outside of the
> transaction context.
>
> see,
> http://www.eclipse.org/eclipselink/api/2.0.1/org/eclipse/per sistence/config/PersistenceUnitProperties.html#JDBC_SEQUENCE _CONNECTION_POOL
>
>
> Also if you use SEQUENCE id generation it will not have this issue.
>]]>Brett Bergquist2010-05-06T19:59:14-00:00Re: Is it possible to run a @TableGenerator in a separate transaction?
https://www.eclipse.org/forums/index.php/mv/msg/167551/532575/#msg_532575
]]>James Sutherland2010-05-10T13:37:26-00:00Re: Is it possible to run a @TableGenerator in a separate transaction?
https://www.eclipse.org/forums/index.php/mv/msg/167551/532611/#msg_532611
James wrote:
> That looks ok.
>]]>Brett Bergquist2010-05-10T14:34:49-00:00