Hi,
I have a list of a specified entity.
I would like to intercept modification to create new entity.
Now, I use the onChange event to run action-method. It works. I success to create a new object, but I cannot save it. This is the given error when save :
[p-nio-88-exec-3] com.axelor.meta.ActionHandler : null
java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.axelor.meta.ActionHandler.call(ActionHandler.java:185)
at com.axelor.meta.schema.actions.ActionMethod.evaluate(ActionMethod.java:76)
at com.axelor.meta.schema.actions.Action.execute(Action.java:98)
at com.axelor.meta.schema.actions.Action.wrap(Action.java:107)
at com.axelor.meta.schema.actions.ActionGroup.evaluate(ActionGroup.java:230)
at com.axelor.meta.schema.actions.Action.execute(Action.java:95)
at com.axelor.meta.schema.actions.Action.wrap(Action.java:107)
at com.axelor.meta.ActionHandler.execute(ActionHandler.java:453)
at com.axelor.meta.ActionExecutor.execute(ActionExecutor.java:43)
at com.axelor.meta.ActionExecutor$$EnhancerByGuice$$fd4b78b8.CGLIB$execute$0(<generated>)
at com.axelor.meta.ActionExecutor$$EnhancerByGuice$$fd4b78b8$$FastClassByGuice$$65846e73.invoke(<generated>)
at com.google.inject.internal.cglib.proxy.$MethodProxy.invokeSuper(MethodProxy.java:228)
Caused by: javax.persistence.TransactionRequiredException: no transaction is in progress
at org.hibernate.internal.SessionImpl.checkTransactionNeeded(SessionImpl.java:3461)
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1425)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1421)
at com.axelor.db.JPA.persist(JPA.java:128)
at com.axelor.db.JPA.save(JPA.java:159)
at com.axelor.db.JpaRepository.save(JpaRepository.java:85)
at fr.elikill58.db.Generator.myAction(Generator.java:68)
... 97 common frames omitted
My code :
public void myAction(ActionRequest request, ActionResponse response) {
MyObjectRepository repo = Beans.get(MyObjectRepository.class);
Map<String, Object> contentOfObject = new HashMap<>();
MyObject obj = repo.save(repo.create(contentOfObject)); // (this line create error)
}