如何避免JPA 2.0 + Spring 3.0中的ID生成并发? [英] How to avoid ID Generation Concurrency in JPA 2.0 + Spring 3.0?

查看:78
本文介绍了如何避免JPA 2.0 + Spring 3.0中的ID生成并发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Web应用程序中,我在JPA ID Generation中获得了Concurrency Problem. 我使用Table生成策略.我已经获得了JPA ID生成的并发问题.

In my web application, I get the Concurrency Problem in JPA ID Generation. I use Table generation strategy. I already get Concurrency Issue of JPA ID Generation.

如何避免在JPA ID生成中使用Concurrency Problem? 有什么更好的ID生成方式? Spring 3.0可以避免这种情况吗?

How can I avoid Concurrency Problem in JPA ID Generation? What will be better way for ID generation? Does Spring 3.0 have a way to avoid it?

实际上,如果使用其他ID生成策略,我会担心数据库的依赖性.

Actually, I worry about the database dependency if I use other id generation strategy.

推荐答案

EclipseLink通常将使用单独的事务来分配生成的ID.如果您使用JTA数据源,则不能使用它,除非您在persistence.xml中也提供了非jta数据源.

EclipseLink will normally use a separate transaction for allocating generated ids. If you use a JTA DataSource then it cannot, unless you also provide a non-jta-datasource in your persistence.xml.

此外,如果您提早触发数据库事务(例如刷新),那么除非指定了顺序连接池,否则表ID的生成将必须使用事务连接.

Also if you trigger a database transaction early (such as a flush) then table id generation will have to use the transactional connection unless you specify a sequence connection pool.

看, http://www.eclipse.org/eclipselink/documentation /2.4/jpa/extensions/p_connection_pool_sequence.htm#BABIDAGH

这篇关于如何避免JPA 2.0 + Spring 3.0中的ID生成并发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆