transactional

CMT transactions

六眼飞鱼酱① 提交于 2019-12-11 10:08:29
问题 One more question from my side ... If I have a stateless service (Stateless Session Bean) as facade (say GlobalService) which methods invokes several other services (again SLSBs, say FooService and BarService): @Stateless @Remote(GlobalService.class) @TransactionManagement(TransactionManagementType.CONTAINER) public class GlobalServiceBean implements GlobalService{ private Logger log = Logger.getLogger(GlobalServiceBean.class); @EJB private FooService fooService; @EJB private BarService

Why data wasn't saved when I use @Transactional annotation?

青春壹個敷衍的年華 提交于 2019-12-11 07:22:48
问题 Colleagues, could you help me with @Transactional annotation. My aim is to pass DB transaction management to Spring and in current case save data in DB. I have two methods in DAO class: @Component public class OdValuesDAO { static final Logger LOG = Logger.getLogger(OdValuesDAO.class.getName()); @Autowired // @PersistenceContext(unitName = "PersistenceUnit") @Qualifier("emR") private EntityManager em; public void addOdValue (OdValuesEntity odValuesEntity) { LOG.info(odValuesEntity.toString())

Datanucleus: moving from @Transactional to non-transactional

落爺英雄遲暮 提交于 2019-12-11 04:07:13
问题 I am using Datanucleus, JDO and Spring's declarative @Transactional management woven with Aspect-J. But when a 'normal' method gets a persistent object from a @Transactional method, the object's state will become transient (the persistence manager seems to be removed) and the object is no longer persistent. Example: public class Example { public void test() throws Exception { Login l = getLogin(); JDOHelper.getObjectState(l); // transient instead of persistent l.getSomeOtherPersistentObj()

In a Transactional function, calling clear() detach all entities?

末鹿安然 提交于 2019-12-11 02:41:48
问题 I am using Hibernate as JPA provider and in a function, I am creating an instance of different entities. Once I call clear() for one entity, I can't persist() the other entities. My code is pretty more complicated, and at a point I am obliged to call flush() and clear() for one type of entities (and NOT for the other types) in order to free some memory. A simplification of my code is as follow: @Transactional void function() { EntityType1 entity1 = new EntityType1(); EntityType2 entity2 = new

Error when retrying method after OptimisticLockException - org.postgresql.util.PSQLException: This statement has been closed

浪尽此生 提交于 2019-12-11 00:47:33
问题 I have method: public void changeItemName(long id, String nmae) { Item item = itemDAO.find(id); item.setName(name); try { itemDAO.save(item); } catch (RollbackException | OptimisticLockException | StaleStateException e) { logger.warn("Retry method after " + e.getClass().getName()); itemDAO.clear(); changeItemName(id, name); } } First, I manually provoke OptimisticLockException by setting higher version, so it goes to catch block, clears EntityManager and retries the method. When retrying, the

Spring , Transactions , Hibernate Filters

风格不统一 提交于 2019-12-10 21:42:36
问题 I am using declarative transactions in Spring. I have a service layer which is annotated with "Transactional". This service layer calls the DAO. I need to enable a hibernate filter in all the dao methods. I don't want to have to explicitly call teh session.enablefilter each time. So is there a way using spring transaction aop etc such that a intercepter can be called when the hibernate session is created? My Service layer: @Service("customerViewService") @Transactional public class

Seam @Transactional annotation not working?

假如想象 提交于 2019-12-10 20:19:06
问题 I'm using the @Transactional annotation on a seam component similar to: @Name( "myComponent" ) @AutoCreate public class MyComponent { public void something() { ... doWork(); } ... @Transactional protected void doWork() { try { log.debug( "transaction active: " + Transaction.instance().isActive() ); } catch (Exception ignore) {} // some more stuff here that doesn't appear to be inside a transaction } } In the "some more stuff" section, I'm modifying some Hibernate entities and then had a bug

EntityManager + @Transactional

时光总嘲笑我的痴心妄想 提交于 2019-12-10 17:14:48
问题 @Service @Repository @Transactional public class VideoService { @PersistenceContext EntityManager entityManager; public void save(Video video) { Video video1 = new Video(); entityManager.persist(video1); } <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"> <persistence-unit name="video_pu" transaction-type="RESOURCE_LOCAL" > <provider>org.hibernate.ejb.HibernatePersistence</provider> <properties> <property name="hibernate.hbm2ddl.auto" value="create-drop" /> <property

Grails 2.3 IntegrationSpec cannot be transactional false

心不动则不痛 提交于 2019-12-10 17:07:56
问题 I upgrade to Grails 2.3 recently and try to migrate all old tests to spock integration test. But it fails at cleanup because my test is non-transactional. The Grails doc says test can be non-transactional, but we need to handle it manually, but it seems not quite right here. as I am getting this error in every integration test extending IntegrationSpec java.lang.IllegalStateException: Cannot deactivate transaction synchronization - not active at grails.test.spock.IntegrationSpec.cleanup

Use Spring @Transactional in Scala

倾然丶 夕夏残阳落幕 提交于 2019-12-10 16:14:31
问题 We have a mixed Java and Scala project, which uses Spring transaction management. We are using the Spring aspects to weave the files with @Transactional annotated methods. The problem is, that the Scala classes aren't woven with the Spring transaction aspects. How can I configure Spring to regard the transaction in Scala? 回答1: Spring needs your transaction boundary to begin with Spring-managed beans, so this precludes @Transactional Scala classes. It sounds like the simple solution is to make