Grails GORM Multi Tenant Lazy Load Not working
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
Recently I upgrade Our Old Custom multi tenant system to Grails 4 Multi Tenant, here seeing Lazy Loading not working
Domain
1. Page
1. many to many with MetaTags
Service
```
@CurrentTenant
PageService
public Page getSitePage(String _url) {
return Page.where {
url == _url
isInTrash == false
isActive == true
visibility != DomainConstants.PAGE_VISIBILITY.HIDDEN
}.get();
[}]
```
When i tried to access the metaTags from GSP it's giving Error
```
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.xyz.Page.metaTags, could not initialize proxy - no Session
at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:602)
at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:217)
at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:581)
at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:148)
at org.hibernate.collection.internal.PersistentBag.iterator(PersistentBag.java:303)
at gsp_core_layoutssitepage_gsp$_run_closure1.doCall(gsp_core_layoutssitepage_gsp.groovy:69)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
```

Contributor guide
Research direction
Start with PageService.getSitePage and the Page.metaTags association described in the report, then trace the GSP access at line 69 where the LazyInitializationException occurs. Reproduce the multi-tenant query and GSP rendering path, and confirm that metaTags can be accessed without the reported no-Session failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100