Reputation: 3934
just trying to persist a relationship between GORM entities, and an overflow error appends on mapping during save.
1) I create a manyTomany relationship between User and DataStore:
User entity:
...
static belongsTo = DataStore
static hasMany = [groups: Groups,dataStore:DataStore]
Profile profile
Contacts contact
DataStore dataStore
...
DataStore entity:
...
static belongsTo = [service:Service]
static hasMany = [users:User]
Service service
List<User> users
...
2) Calling the service from a controller to save datas:
UserRole.create user, roleCustomer, true
UserRole.create user, roleAdmin, true
dataStoreService.createDS('ds',profile.service,user)
3) Service logic:
@Transactional
def createDS(ds,service,user) {
def key = service.domainkey
if (user && key) {
DataStore ds = new DataStore(ds:ds)
ds.validate() ? ds.save(flus:true) : ds.errors.allErrors.println()
ds.addToUsers(user).save(flush:true)
service.addToDataStore(ds).save(flush:true)
user.setDataStore(ds)
...}
4) The weird error i need to solve:
Stacktrace follows: org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Executing action [sendOrder] of controller [$$.StoreController] caused exception: Runtime error executing action at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195) at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63) at net.bull.javamelody.JspWrapper.invoke(JspWrapper.java:149) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:259) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:202) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:175) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) at java.lang.Thread.run(Thread.java:680) Caused by: org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Runtime error executing action ... 9 more Caused by: java.lang.reflect.InvocationTargetException ... 9 more Caused by: java.lang.StackOverflowError at org.apache.commons.validator.EmailValidator.stripComments(EmailValidator.java:246) at org.apache.commons.validator.EmailValidator.isValid(EmailValidator.java:95)
Any help please?
Upvotes: 0
Views: 802
Reputation: 3934
just redone my model following hibernate doc:
class User implements Serializable {
static hasMany = [dataStores:DataStore,contacts:Contacts,groups: Groups]
Profile profile
Contacts contacts
List<DataStore> dataStores
with contraint: dataStores nullable:true
And DS entity:
class DataStore implements Serializable{
static hasMany = [users:User,contacts:Contacts]
static belongsTo = [service:Service]
Service service
User users
removes definetely the several overflows and keeps the model reliable.
Upvotes: 0
Reputation: 2383
EDIT
After looking again at the stack trace the problem has nothing to do with Melody (maybe? maybe not?) but let us know what was wrong).
Check the email reference of the User (Not sure in which sub-domain class it is located, maybe contact class? print it or use a debugger to inspect the domain values and then double-check your constraints) . If the email issue is not related to your domain classes, then double-check again melody...
org.apache.commons.validator.EmailValidator.isValid(EmailValidator.java:95)....
-- Still double-check what Melody is doing.
If the problem was related to Melody, please let us know, just for personal information. I've seen so many random issues from people using that plugin, it looks useful but buggy.
Upvotes: 1
Reputation: 3709
You have the variable dataStore
defined twice: once in your hasMany
and once as a straight reference.
Try:
User entity:
...
static belongsTo = [datastore: DataStore]
static hasMany = [groups: Groups,dataStores:DataStore]
Profile profile
Contacts contact
...
Upvotes: 0