transactional

Grails - @Transactional, Connection is read-only

房东的猫 提交于 2019-12-13 02:38:05
问题 I used static scaffolding to create CRUD-methods for my Test domain class. When using the created TestController only I had no problems whatsoever saving new Test objects. However, I wanted to extend the functionality and implemented a corresponding TestService class. Doing so I now always get an error on saving a Test object: Connection is read-only. Queries leading to data modification are not allowed And here it started to malfunction. Following the code of TestService . If I understood it

Mixing declarative beans and annotated beans: org.hibernate.HibernateException No Session found for current thread

人盡茶涼 提交于 2019-12-12 22:41:21
问题 I get "No Session found for current thread". I suppose the problem is in mixing declarative xml beans and annotated beans. Following, I'll resume my config. MyLibrary Project Spring 3.1.4 Hibernate 4 applicationContext.xml <tx:annotation-driven transaction-manager="transactionManager" /> <context:component-scan base-package="com.mycompany.dao.core, com.mycompany.services.core, com.mycompany.permissionEvaluator" /> <import resource="model-core-security.xml" /> <bean id="transactionManager"

Spring @Transactional - javax.persistence.TransactionRequiredException

纵然是瞬间 提交于 2019-12-12 20:41:16
问题 In the following schema Controller -> Service -> DAO I'm trying to make Service operations @Transactional in my UserService.fooFunction() i call Entity e = dao.find(key) e.setProperty(something) dao.update(e) in dao.update(e) at the end there is em.flush() //EntityManager obtained by @PersistenceContext annotation (injected by spring IoC) Calling flush() throws a persistenceException: javax.persistence.TransactionRequiredException No externally managed transaction is currently active for this

Hibernate ConstraintViolationException on SELECT query

大城市里の小女人 提交于 2019-12-12 10:09:39
问题 I have a Persistent Class with multi-field unique constraint on it. But defined unique constraint is not sufficient for me because on one those field non-equal but similar values are unique too. I implement a checkUniqueConstraint method. In add and update methods of DAO class, I call checkUniqueConstraint before adding or updating persist object. checkUniqueConstraint method just run a SELECT query to find object similar to input and throw a check Exception where find some ones. public class

@ManagedBean and @Transactional - bug in Spring? Workarounds?

两盒软妹~` 提交于 2019-12-12 03:08:23
问题 I had the following JSF backing bean in my Webapp @ManagedBean class MyBackingBean implements Serializable { private MyHibernateRepository repository; ... @Transactional public void save() { .... repository.save(myObject); } } When it gets to the repository.save method call - I get the following error no transaction is in progress I've got two questions Is this because of a bug like this? I believe there are two workarounds - are there any others? 2.1 First workaround - using

Spring @Transactional propagation is not working

时光怂恿深爱的人放手 提交于 2019-12-12 02:24:38
问题 I have a very simple code comprising of Service -> RequestProcessor -> DAO having 2-3 classes (interface, abstract, concrete) in each layer. Service layer:- public interface Service { public void saveOrUpdate(Object entity, String operationName); } } public abstract class AbstractService implements Service{ public abstract ReqProcessor getRP(); @Override public void saveOrUpdate(Object entity, String operationName) { ReqProcessor hiberTestRP = getRP(); hiberTestRP.saveOrUpdate(entity,

how to update sequence number in mongodb safely

。_饼干妹妹 提交于 2019-12-11 23:46:27
问题 In my mongodb database, there is a 'messages' collection, it has a field 'order' which values integer msg1.order=1, msg2.order=2, msg3.order=3, msg4.order=4, msg5.order=5, ... for each message, represents an ordered sequence of a sub-collection of messages. while, these messages can be re-sorted, via web page, using jquery.sortable. for example, If I move message on position No.3 to No.1, then I should change 'order' values to msg1.order=2, msg2.order=3, msg3.order=1, msg4.order=4, msg5.order

LazyInitializationException due to no session defined in “parent” application context in Hibernate 3 in a moduled Spring application using annotations

前提是你 提交于 2019-12-11 23:29:08
问题 I am fairly new to both Hibernate3 and Spring3, and I'm having an issue related to initializing lazy references of a hibernate object. I have a fully contained dao and service. The domain objects are created using hbm2java and a reverse engineering file. I have followed some best practices I have found using Annotations (@Transactional) on my service objects. (This guide was VERY helpful to me http://carinae.net/2009/11/layered-architecture-with-hibernate-and-spring-3/) The issue that I am

Clustering transactional data using PAM in R?

最后都变了- 提交于 2019-12-11 16:26:11
问题 I need to group sets of transactions in different groups. My data in a text file as this format: T1 17 20 22 35 37 60 62 T2 39 51 53 54 57 65 73 T3 17 20 21 22 34 37 62 T4 20 22 54 57 65 73 45 T5 20 54 57 65 73 75 80 T6 2 20 54 57 59 63 71 T7 2 20 22 57 59 71 66 T8 17 20 28 29 30 34 35 T9 16 20 28 32 54 57 65 T10 16 20 22 28 57 59 71 - - and so on, over 5000 lines. Each line represents one transaction. What I did so far: txIn<-read.transactions("data2.txt",format="basket",sep=" ") d<

JPA @Entity not managed after creation?

旧城冷巷雨未停 提交于 2019-12-11 14:16:40
问题 I have a simple controller method, where I create a new object Car and then set its name to Audi : @GetMapping(value = "/resource") public ResponseEntity visit() { Car car = carRepo.save(new Car("VolksWagen")); // Car should be managed now? car.setName("Audi"); // <-- has no effect on database state return ResponseEntity.ok().build(); } In the database, it never becomes an Audi , but stays a VolksWagen . Why does this happen? Shouldn't the newly created Car be in managed state for the