transactional

No transaction starts within Spring @Transactional method

断了今生、忘了曾经 提交于 2019-12-01 08:50:42
问题 I run into strange problem while developing application using Spring (3.0.5), Hibernate (3.6.0) and Wicket (1.4.14). The problem is: i cannot save or modify any object into database. By 'cannot' I mean that all changes in object or calls to EntityManager.persist(foo) are simply, silently ignored. Selects work. Sample case is simple - on some wicket page i try to save object into database, like follows public class ComicDetailsPage extends PublicBasePage { @Override protected void onConfigure(

Job level Transactionality in Spring Batch

心不动则不痛 提交于 2019-12-01 07:39:41
问题 I know right now there is no such thing as inter-step transactionality in Spring-Batch. I'm developing a complex batch job, with many steps performing several actions in database, and each one is related with the others, in such way that each one of them belongs to the same transaction. The way I understand the Spring-Batch paradigm I'm bound to use one-step job in order to have transactionality. Is there any thought (or any other way) to have some kind of job-level transactionality in lately

Alternatives to using Transactional NTFS

纵饮孤独 提交于 2019-12-01 06:33:08
Given that Microsoft has deprecated Transactional NTFS (TxF) : Microsoft strongly recommends developers utilize alternative means to achieve your application’s needs. Many scenarios that TxF was developed for can be achieved through simpler and more readily available techniques. Furthermore, TxF may not be available in future versions of Microsoft Windows. While TxF is a powerful set of APIs, there has been extremely limited developer interest in this API platform since Windows Vista primarily due to its complexity and various nuances which developers need to consider as part of application

No rollback for ConstraintViolationException in transactional service

梦想与她 提交于 2019-11-30 18:20:32
问题 I've a service method called add() which is annotated with @Transactional . I call it but when a ConstraintViolationException occurs inside corresponding DAO method it'll rollback the transaction even when I specify not to. I expect that ConstraintViolationException to be caught and instead of it NotFoundException checked exception would be thrown. @Override @Transactional(noRollbackFor = ConstraintViolationException.class) public User add(User user) throws NotFoundException { try { result =

How do you test Spring @Transactional without just hitting hibernate level 1 cache or doing manual session flush?

雨燕双飞 提交于 2019-11-30 15:17:09
问题 Using Spring + Hibernate and transactional annotations. I'm trying to test the following: call a method that changes a User object then calls a @Transactional service method to persist it read the object back from the DB and insure it's values are correct after the method The first problem I had was reading the User object in step 2 just returned the one in the Hibernate level 1 cache and did not actually read from the database. I therefore manually evicted the object from the cache using the

How do you test Spring @Transactional without just hitting hibernate level 1 cache or doing manual session flush?

匆匆过客 提交于 2019-11-30 14:00:53
Using Spring + Hibernate and transactional annotations. I'm trying to test the following: call a method that changes a User object then calls a @Transactional service method to persist it read the object back from the DB and insure it's values are correct after the method The first problem I had was reading the User object in step 2 just returned the one in the Hibernate level 1 cache and did not actually read from the database. I therefore manually evicted the object from the cache using the Session to force a read from the database. However, when I do this, the object values are never

Spring3 's @Transactional @Scheduled not committed to DB?

北慕城南 提交于 2019-11-30 13:41:24
This is my 1st time trying Spring3's @Scheduled , but found I cannot commit to DB. This is my code : @Service public class ServiceImpl implements Service , Serializable { @Inject private Dao dao; @Override @Scheduled(cron="0 0 * * * ?") @Transactional(rollbackFor=Exception.class) public void hourly() { // get xxx from dao , modify it dao.update(xxx); } } I think it should work , I can see it starts-up hourly and load xxx from DB , but data is not committed to DB. There's been tx:annotation-driven in spring's xml : <bean id="entityManagerFactoryApp" class="org.springframework.orm.jpa

Why does @Transactional save automatically to database

核能气质少年 提交于 2019-11-30 12:04:32
问题 I have a method annotated with @Transactional. I retrieve an object from my DB, change a field, and then return from the method. Without saving my object, the database gets updated anyway which is strange. Could you please tell me how to avoid this beahvior? 回答1: This behaviour is one of the main purposes of transactionality. Before the transactional method is about to return, the transaction commits, meaning all changes to the managed entities are flushed to the database. If an error occurs,

Why does @Transactional save automatically to database

拜拜、爱过 提交于 2019-11-30 03:39:16
I have a method annotated with @Transactional. I retrieve an object from my DB, change a field, and then return from the method. Without saving my object, the database gets updated anyway which is strange. Could you please tell me how to avoid this beahvior? This behaviour is one of the main purposes of transactionality. Before the transactional method is about to return, the transaction commits, meaning all changes to the managed entities are flushed to the database. If an error occurs, the transaction will be rolled back, meaning that no changes will be committed to the database. You are

Spring Propagation examples in layman's terms

为君一笑 提交于 2019-11-29 19:24:15
The Spring docs do a fantastic job of describing transactional propagation properties. However, I was wondering if there are any well-known, real-world examples available which describe each of these properties more thoroughly in layman's terms? Brad PROPAGATION_REQUIRED class Service { @Transactional(propagation=Propagation.REQUIRED) public void doSomething() { // access a database using a DAO } } When doSomething() is called it will start a new transaction if the caller has not already started a transaction . If the caller of this method has already started a transaction then the callers'