Replies: 1 comment 2 replies
-
Maybe this is not related, but we did some AspectJ related fix in #1841
try to disable EclipseLink |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello all,
I am working on migrating a legacy Java 11, Spring 5/data/jpa, and EclipseLink 2.7 cloud server application to Java 17, Spring 6.1.x, and EclipseLink 4.0.x. We use load-time-weaving with aspectj and spring-instrument agents.
The specific dependency versions currently in use are:
We use single table multitenancy and heavily rely on FetchType.LAZY for entity relationship mappings (
@OneToOne
,@OneToMany
, etc). I have enabled FINE logging for EclipseLink and confirmed that the entity classes are being found and registered by the EL weaver, with logs such as:With the updated dependencies, during server start-up EclipseLink reports the following warning for most/all of our entities that use FetchType.LAZY:
Previously when we were running Spring 5/EclipseLink 2.7 no warnings of this type were logged. This has led me to believe that the weaving of entity classes is not working correctly, and I have not been able to figure out why. During server start up, we are also seeing exceptions such as:
I've been able to temporarily get around this issue by deleting the entity relationship mappings/joins out of the entity classes and replacing them with external manual database operations. We only have couple entities that are being accessed while the server is starting up which completely halts it from launching.
However this is only a bandaid fix and does not fix the underlying problem. Certain API's/web pages can be accessed on our site while the user is not logged in and thus not yet associated to a tenant id. In these contexts the 'eclipselink.tenant-id' jpa property is null. When fetching an entity that has a relationship with another entity annotated
@Multitenant
EclipseLink throws an error such as the following:We do have a custom implementation of EntityManagerFactory that sets the 'eclipselink.tenant-id' property. I have hit a breakpoint where the exception is being thrown and confirmed that the property does exist in the jpa property map, but it is null (as expected) due to the user being in a tenantless context. I believe the above error is caused by lazy loading being broken, so associated multitenant entities are being eagerly fetched and then failing due to the null tenant id when they were not being fetched previously due to the lazy fetching.
We do not configure EclipseLink through persistence.xml and instead use Java configuration via Spring's LocalContainerEntityManagerFactoryBean:
Our entities are defined like this and share a BaseEntity abstract parent class annotated with @MappedSuperclass:
Apologies for the long-winded post, but I was hoping someone might have some ideas on what is causing our issue with entity weaving and FetchType.LAZY. I am not sure what has changed in between these dependency versions that have caused this issue, and I've been unable to find useful migration documentation between EclipseLink 2.7 and 4.0.x. We are seeing the same issue on EclipseLink 3.x. Thank you for your time, Andrew
Beta Was this translation helpful? Give feedback.
All reactions