只是试图保持 GORM 实体之间的关系,并且在保存期间在映射上附加溢出错误。
1)我在用户和数据存储之间创建了一个manyTomany关系:
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)从控制器调用服务以保存数据:
UserRole.create user, roleCustomer, true
UserRole.create user, roleAdmin, true
dataStoreService.createDS('ds',profile.service,user)
3)服务逻辑:
@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)我需要解决的奇怪错误:
Stacktrace 如下:org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException:执行控制器 [$$.StoreController] 的操作 [sendOrder] 导致异常:在 grails.plugin.cache.web 执行操作时出现运行时错误。 filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195) 在 grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63) 在 net.bull.javamelody.JspWrapper.invoke(JspWrapper.java:149)在 net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:259) 在 net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:202) 在 net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java :175) 在 java.util.concurrent 的 java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)。ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) at java.lang.Thread.run(Thread.java:680) 原因:org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: 运行时错误执行动作... 9 更多原因:java.lang.reflect.InvocationTargetException ... 9 更多原因:org.apache.commons.validator.EmailValidator.stripComments(EmailValidator.java:246) 的 java.lang.StackOverflowError org.apache.commons.validator.EmailValidator.isValid(EmailValidator.java:95)StackOverflowError at org.apache.commons.validator.EmailValidator.stripComments(EmailValidator.java:246) at org.apache.commons.validator.EmailValidator.isValid(EmailValidator.java:95)StackOverflowError at org.apache.commons.validator.EmailValidator.stripComments(EmailValidator.java:246) at org.apache.commons.validator.EmailValidator.isValid(EmailValidator.java:95)
请问有什么帮助吗?