Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

In some cases TenantUser class prevents data from saving #51

Copy link
Copy link
@belyaev-andrey

Description

@belyaev-andrey
Issue body actions

Environment

  • Platform version: 7.2.4
  • Addon version: 2.0.2

Description of the bug or enhancement

Checkout Petclinic app from https://github.com/cuba-platform/cuba-petclinic
Install Multitenancy Add-On
Create the database and run application

E.R. Application will start. All entities are not tenant-specific, so everything should work
A.R. Application fails on startup, method com.haulmont.sample.petclinic.core.VisitTestDataCreation#commit fails.

If we remove com.haulmont.addon.sdbmt.entity.TenantUser class from the add-on, the application starts.

Error:

20:08:30.796 ERROR c.h.c.c.s.AbstractWebAppContextLoader   - Error initializing application
java.lang.IllegalStateException: An attempt to save an entity with reference to some not persisted entity. All newly created entities must be saved in the same transaction. Put all these objects to the CommitContext before commit.
	at com.haulmont.cuba.core.sys.aop.CascadePersistExceptionAspect.changeCascadePersistMessage(CascadePersistExceptionAspect.java:38) ~[cuba-core-7.2.4.jar:7.2.4]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:626) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:66) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at com.sun.proxy.$Proxy283.commit(Unknown Source) ~[na:na]
	at com.haulmont.cuba.core.app.DataManagerBean.commit(DataManagerBean.java:188) ~[cuba-core-7.2.4.jar:7.2.4]
	at com.haulmont.cuba.core.app.DataManagerBean.commit(DataManagerBean.java:220) ~[cuba-core-7.2.4.jar:7.2.4]
	at com.haulmont.sample.petclinic.core.VisitTestDataCreation.commit(VisitTestDataCreation.java:126) ~[petclinic-core-2.0.jar:na]
	at com.haulmont.sample.petclinic.core.VisitTestDataCreation.createData(VisitTestDataCreation.java:65) ~[petclinic-core-2.0.jar:na]
	at com.haulmont.sample.petclinic.core.TestdataOnApplicationStart.appStarted(TestdataOnApplicationStart.java:19) ~[petclinic-core-2.0.jar:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:an]
....
	Suppressed: java.lang.IllegalStateException: During synchronization a new object was found through a relationship that was not marked cascade PERSIST: com.haulmont.addon.sdbmt.entity.TenantUser-78c1b6c3-f217-dc2e-8af6-e1d502256dd0 [detached].
		at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.discoverUnregisteredNewObjects(RepeatableWriteUnitOfWork.java:315) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
		at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.calculateChanges(UnitOfWorkImpl.java:768) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
		at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.writeChanges(RepeatableWriteUnitOfWork.java:443) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
		at org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush(EntityManagerImpl.java:974) ~[org.eclipse.persistence.jpa-2.7.3-6-cuba.jar:na]

Metadata

Metadata

Labels

type: bugSomething isn't workingSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.