问题标签 [transactional]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
hibernate - Spring,Hibernate @OneToOne 事务测试问题
我在测试我的 DAOObject 时遇到问题。我有两个由@oneToOne 关系链接的实体。课程是:
和
在 DAO 中,我执行以下操作:
如您所见, session.flush() 和 Hibernate.Initalize 都不起作用。最终用户未分配给设备。如果我删除@Transactional,...一切正常。有没有办法让它工作?否则我总是不得不在测试后手动删除数据库中创建的实体,这很烦人。
希望得到答复。
提前致谢。
c# - 使用 TxNTFS 的奇怪间歇性错误
我正在使用事务性 NTFS 读取和写入文件系统上的文件,并且我注意到应用程序遇到间歇性故障,这只能通过重新启动应用程序来解决。错误的堆栈跟踪是:
IKernelTransaction 是一个 COM 接口,我可以使用它来处理:
这里
我的代码与http://msdn.microsoft.com/en-us/library/cc303707.aspx非常相似
问题是我找不到此 COM 错误 0xD0190052 的任何信息。只要知道这个错误代码是什么就会有很大帮助。
谢谢
java - spring multiple @transactional datasource
I need to use two different dataSources/transactionManagers for different methods. The concept with @Transaction(value="txManagerABC") and a defined qualifier in the applicationContext for the transaction manager is perfect. (As seen in Spring multiple @Transactional datasources)
Unfortunately I need to do the same thing with Spring 2.5. Does anyone have an idea how to solve this?
spring - Spring @Transactional 如何将不同的方法附加到同一个事务
我对事务配置子类化有疑问。
我有一个具有此方法的 A 类:
然后B类子类A并覆盖activate方法
我需要单独执行超级方法时有自己的事务,但是当执行B类的方法时,所有操作都需要参与同一个事务。
任何想法?
sql - 带有不兼容数据类型的表上的事务复制
我正在尝试在 2008 年实现事务复制。发布者和订阅者都在 2008 版本中。到目前为止一切都很好。
发布者数据库处于 2005 兼容模式。它有一个表,其中有两列数据类型为“日期”,这是 2008 年新增的。因此,对于复制,当在拍摄初始快照时生成 bcp 文件时,因为发布者处于 2005 模式,它会生成一个快照,认为它将在 2005 模式数据库上应用相同的内容,因此快照失败,因为 2005 年不支持“日期”数据类型。
请提出一些补救措施,而不是更改兼容性级别。是否有任何选项我可以选择告诉快照代理它应该为真正的 2008 订阅者生成快照。
提前致谢!
钱丹·贾
java - Spring / Hibernate / appfuse 中的事务
作为此处问题的后续: Spring 2.0 Annotations and ant
我们能够使注释正常工作(@Transactional),并且还尝试手动编写事务。
在这两种情况下,我们都会遇到一些问题。这是一个 appfuse 1.9.4 项目,我们手动升级到更新的 Hibernate 项目。这是使用 Spring 2.0。
我想做的是将整个 Web 服务包装在数据库“事务”中,以便整个“调用”是原子的。我知道“最简单”的方法是使用@Transactional?
为此,我们在类中添加了:
然后,在方法(公开的)旁边,我们做了:
在 applicationContext-hibernate.xml 中,我添加了:
现在,当我启动 Tomcat 时,我得到了这个可爱的错误:
我们使用的是 Spring 2.0,但没有“配置”任何 AOP。
有任何想法吗?
或者,我很乐意使用 Transaction.commit() 来执行此操作,但走这条路线会引发有关事务从未启动的消息。
谢谢!
spring - 使用 Spring 事务管理器和 Maven 进行 AspectJ 加载时间编织
我正在尝试使用 Spring 的事务管理器启用加载时间编织,但运气不佳。目前我只是试图在 @Transactional 方法中运行一个简单的 em.persist() 但它似乎没有运行事务,如下所示:TransactionSynchronizationManager.isActualTransactionActive()
我的应用程序上下文文件包含:
我的 pom.xml 包含:
似乎设置存在一些问题,虽然我遇到了很多关于如何实现 AspectJ / 加载时间编织的示例,但它们似乎都在使用 Eclipse 插件,其中 1)我试图避免使用任何类型插件和 2)我正在使用 Intellij。任何帮助将非常感激。
谢谢。
spring - Datanucleus:从@Transactional 迁移到非事务性
我正在使用@Transactional
与 Aspect-J 结合的 Datanucleus、JDO 和 Spring 的声明式管理。
但是当“正常”方法从方法中获取持久对象时@Transactional
,对象的状态将变为瞬态(持久性管理器似乎已被删除)并且对象不再是持久性的。
例子:
为什么会这样?如何在不添加@Transactional
不需要交易的地方的情况下修复它?以下确实(显然)有效,因此这表明可以建立事务连接和非事务连接:
- @Transactional 方法调用@Transactional 方法
- @Transactional 方法调用普通方法
- 普通方法调用普通方法
如果我打电话dao.refresh(l)
,我会得到:'带有 id "" 的对象由不同的对象管理器管理',所以也许 Spring 正在使用与 DAO 不同的持久性管理器,这是原因吗?
这是我的弹簧配置(可能是相关的):
java - POJO DTO 的 JPA 同步/提交错误,即使我不想保存它
由于缺乏关键词来捕捉这个场景,让我继续描述它。类已被简化。
鉴于这种:
在以下情况下,discountService.hasDiscount 会引发异常:
- 在随后的迭代中
- 和之前的迭代一样,ItemDto 被打折了。
例外是:
在堆栈跟踪的某处,您会看到:
问题是方法调用在下面使用了 @Transactional 的 dao 方法(即使它只是一个复杂的查询,也可能有充分的理由)。当 JPA Tx 管理器在方法调用结束时完成其工作时,它会看到 pojo 已修改并尝试同步它。ItemDto pojo 确实有 @Entity,因为在 ItemDtoService.getItemDtos 内部使用 getEntityManager().createNativeQuery(nativeSql, ItemDto.class)。其他 5 个类的详细信息在这里:
我究竟做错了什么?
我尝试并使用的一些选项包括:
- 将 Dao 方法上的 (readonly=true) 添加到 @Transactional,因为它们只是查询(尽管负面影响是那些可能由于复杂的查询而有意地进行事务处理,并且可能需要锁定以防止脏读)
- 在控制器中,创建一个单独的循环进行修改,然后它有 2 个循环,1 个用于循环遍历项目并查看哪些是打折的,将这些信息存储在某处以便稍后在第二个循环中引用,这会修改所述 pojos
我正在查看其他选项,如果您发现它的编码方式有问题,请发表评论。
java - Spring @Transaction not starting transactions
I am using Spring 3 with Hibernate 3. I am trying to configure Spring declarative transaction, but no matter what I try, Spring transaction is not getting started.
Here is my configuration
File: applicationContext-hibernate.xml
I have a class ServiceLocatorImpl which implements ServiceLocator interface
It seems to me that all my configuration is correct. But when executeService method is called, TransactionSynchronizationManager.isActualTransactionActive() is always returning false.
Please help me solving this problem. Let me know if any more information required.
Update: I have wired the ServiceLocator into one of the other classes, as follows:
I am using Spring 3.0.0 version.
executeService() is one the method defined in the ServiceLocator interface. I updated the code to throw exception instead of just logging an error. Following is the stack trace, I don't see any proxy creation in this trace. Please help.
Update [Solved]
I got the issue fixed. Before giving the answer as how it was fixed, I need to provide some more information. I am using Spring MVC in my project. The control DispatchServlet is configured in the web.xml. This front controller has a configuration xml file abc-servlet.xml (abc being the servlet name in web.xml). I have other spring configuration files too which are defined as context-param
in web.xml
. One of the file is applicationContext-hibernate.xml
file.
I defined the txManager
and <tx:annotation-driven />
, in the applicationContext-hibernate.xml
file. Today I was wondering whether @Autowired and @Transactional work with together, so I Google the information, and found this thread
The thread talk about similar problem, and this solves the problem.
I implemented one of the suggestion and added <tx:annotation-driven .../> to my servlet's application context xml and it fixes the problem.
Thinking that I also moved my <tx:annotation-driven />
into abc-servlet.xml file and it worked.
My logs are now shoulding the required messages:
[venice] DEBUG [http-8080-1] 27 Sep 2011 14:24:06,312 ServiceLocatorImpl.logTransactionStatus(100) | ServiceLocator:executeService - Active transaction found
Thanks to everyone for Helping. May be this information will be helpful to someone. I would still like to hear about the explanation as why it was not working earlier.