[英]Grails domain functions not working
I problem that seems to be fairly simple but has me stumped since yesterday afternoon. 我的问题似乎很简单,但自昨天下午以来一直困扰我。 My domain class functions don't work (saving and retrieving records).
我的域类功能不起作用(保存和检索记录)。 Using intellij Idea, auto completion still detects the domain fields though so if I type "
myDomain.
" after declaring an object, auto complete will still suggest domain properties though. 尽管使用intellij Idea,自动完成仍会检测域字段,因此,如果我在声明对象后键入“
myDomain.
”,则自动完成仍会建议域属性。 Anyhow, here's what I got: 无论如何,这就是我得到的:
Controller: 控制器:
def update(){
switch(request.getMethod()){
case 'POST':
if(params.fire == 'true'){
def oldClients = Clients.findAll() /* This is where it breaks. Also
note that all other methods of retrieving data doesn't work either,
as well as trying to create and save new records. */
}
break
}
}
Domain: 域:
// I shortened the domain coz the original has a buttload of fields.
class Clients {
String CClientId
String CFirstName
String CSurname
String CEmail
static mapping = {
id name: "CClientId", generator: "assigned"
version false
datasource "dataSourceOld"
cache usage: 'read-only'
}
static constraints = {
CClientId(maxSize: 12)
CFirstName(nullable: true, maxSize: 5)
CSurname(maxSize: 30)
CEmail(maxSize: 30)
}
}
Something else to note is that when I try to declare the domain's constraints the other way, ie CClientId maxSize: 12
instead of how I declared it above I get the cannot resolve symbol
error on CClientId
and the ';', '}' or new line expected
error on the colon following maxSize
, 其他需要注意的是,当我尝试以另一种方式声明域的约束时,即
CClientId maxSize: 12
而不是上面的声明方式,我得到了CClientId
和';', '}' or new line expected
上cannot resolve symbol
错误。 maxSize
,冒号上的';', '}' or new line expected
错误,
Here's the error I get when I try to run my update action: 这是我尝试运行更新操作时遇到的错误 :
.Error
|
2016-06-28 09:42:02,741 [http-bio-7070-exec-10] ERROR errors.GrailsExceptionResolver - MissingMethodException occurred when processing request: [POST] /oneyeargift/adminhome/updateAbases - parameters:
fire: true
No signature of method: unipoint.oyg.domain.old.ClientsOyg.findAll() is applicable for argument types: () values: []
Possible solutions: findAll(), findAll(), findAll(groovy.lang.Closure), findAll(java.lang.Object), findAll(java.lang.String), findAll(groovy.lang.Closure). Stacktrace follows:
Message: No signature of method: unipoint.oyg.domain.old.ClientsOyg.findAll() is applicable for argument types: () values: []
Possible solutions: findAll(), findAll(), findAll(groovy.lang.Closure), findAll(java.lang.Object), findAll(java.lang.String), findAll(groovy.lang.Closure)
Line | Method
->> -2 | newInstance0 in sun.reflect.NativeConstructorAccessorImpl
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 39 | newInstance in ''
| 27 | newInstance . . . . . . . . . . in sun.reflect.DelegatingConstructorAccessorImpl
| 513 | newInstance in java.lang.reflect.Constructor
| 991 | jlrConstructorNewInstance . . . in org.springsource.loaded.ri.ReflectiveInterceptor
| 77 | invoke in org.codehaus.groovy.reflection.CachedConstructor
| 71 | doConstructorInvoke . . . . . . in ''
| 42 | callConstructor in org.codehaus.groovy.runtime.callsite.ConstructorSite
| 57 | defaultCallConstructor . . . . in org.codehaus.groovy.runtime.callsite.CallSiteArray
| 182 | callConstructor in org.codehaus.groovy.runtime.callsite.AbstractCallSite
| 194 | callConstructor . . . . . . . . in ''
| -1 | findAll in unipoint.oyg.domain.old.ClientsOyg$$EPpP6s0O
| 45 | defaultCall . . . . . . . . . . in org.codehaus.groovy.runtime.callsite.CallSiteArray
| 108 | call in org.codehaus.groovy.runtime.callsite.AbstractCallSite
| 112 | call . . . . . . . . . . . . . in ''
| 880 | updateAbases in unipoint.oyg.control.admin.AdminhomeController$$EPpP3IMS
| -2 | invoke0 . . . . . . . . . . . . in sun.reflect.NativeMethodAccessorImpl
| 39 | invoke in ''
| 25 | invoke . . . . . . . . . . . . in sun.reflect.DelegatingMethodAccessorImpl
| 597 | invoke in java.lang.reflect.Method
| 122 | invoke . . . . . . . . . . . . in org.springsource.loaded.ri.ReloadedTypeInvoker$2
| 1288 | jlrMethodInvoke in org.springsource.loaded.ri.ReflectiveInterceptor
| 69 | invoke . . . . . . . . . . . . in org.codehaus.groovy.grails.web.servlet.mvc.MixedGrailsControllerHelper
| -1 | invoke in grails.plugin.cache.web.ProxyAwareMixedGrailsControllerHelper
| 348 | handleAction . . . . . . . . . in org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper
| -1 | handleAction in grails.plugin.cache.web.ProxyAwareMixedGrailsControllerHelper
| 231 | executeAction . . . . . . . . . in org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper
| -1 | executeAction in grails.plugin.cache.web.ProxyAwareMixedGrailsControllerHelper
| 197 | handleURI . . . . . . . . . . . in org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper
| -1 | handleURI in grails.plugin.cache.web.ProxyAwareMixedGrailsControllerHelper
| 118 | handleURI . . . . . . . . . . . in org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper
| -1 | handleURI in grails.plugin.cache.web.ProxyAwareMixedGrailsControllerHelper
| 72 | handleRequest . . . . . . . . . in org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsController
| 48 | handle in org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter
| 328 | doDispatch . . . . . . . . . . in org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet
| 852 | doService in org.springframework.web.servlet.DispatcherServlet
| 882 | processRequest . . . . . . . . in org.springframework.web.servlet.FrameworkServlet
| 789 | doPost in ''
| 646 | service . . . . . . . . . . . . in javax.servlet.http.HttpServlet
| 727 | service in ''
| 305 | internalDoFilter . . . . . . . in org.apache.catalina.core.ApplicationFilterChain
| 210 | doFilter in ''
| 200 | doFilter . . . . . . . . . . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| -1 | doFilter in grails.plugin.cache.web.filter.ehcache.EhcachePageFragmentCachingFilter
| 63 | doFilter . . . . . . . . . . . in grails.plugin.cache.web.filter.AbstractFilter
| 346 | invokeDelegate in org.springframework.web.filter.DelegatingFilterProxy
| 259 | doFilter . . . . . . . . . . . in ''
| 243 | internalDoFilter in org.apache.catalina.core.ApplicationFilterChain
| 210 | doFilter . . . . . . . . . . . in ''
| 70 | doFilter in org.springframework.web.filter.OncePerRequestFilter
| 243 | internalDoFilter . . . . . . . in org.apache.catalina.core.ApplicationFilterChain
| 210 | doFilter in ''
| 70 | doFilter . . . . . . . . . . . in org.springframework.web.filter.OncePerRequestFilter
| 243 | internalDoFilter in org.apache.catalina.core.ApplicationFilterChain
| 210 | doFilter . . . . . . . . . . . in ''
| 70 | doFilter in org.springframework.web.filter.OncePerRequestFilter
| 243 | internalDoFilter . . . . . . . in org.apache.catalina.core.ApplicationFilterChain
| 210 | doFilter in ''
| 749 | invoke . . . . . . . . . . . . in org.apache.catalina.core.ApplicationDispatcher
| 487 | processRequest in ''
| 412 | doForward . . . . . . . . . . . in ''
| 339 | forward in ''
| 318 | forwardRequestForUrlMappingInfo in org.codehaus.groovy.grails.web.util.WebUtils
| 283 | forwardRequestForUrlMappingInfo in ''
| 274 | forwardRequestForUrlMappingInfo in ''
| 203 | doFilterInternal in org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter
| 76 | doFilter . . . . . . . . . . . in org.springframework.web.filter.OncePerRequestFilter
| 243 | internalDoFilter in org.apache.catalina.core.ApplicationFilterChain
| 210 | doFilter . . . . . . . . . . . in ''
| 82 | doFilterInternal in com.linkedin.grails.profiler.ProfilerFilter
| 76 | doFilter . . . . . . . . . . . in org.springframework.web.filter.OncePerRequestFilter
| 243 | internalDoFilter in org.apache.catalina.core.ApplicationFilterChain
| 210 | doFilter . . . . . . . . . . . in ''
| 206 | obtainContent in org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter
| 152 | doFilter . . . . . . . . . . . in ''
| 243 | internalDoFilter in org.apache.catalina.core.ApplicationFilterChain
| 210 | doFilter . . . . . . . . . . . in ''
| -1 | call in javax.servlet.FilterChain$doFilter
| 45 | doFilter . . . . . . . . . . . in org.grails.plugin.resource.DevModeSanityFilter
| 243 | internalDoFilter in org.apache.catalina.core.ApplicationFilterChain
| 210 | doFilter . . . . . . . . . . . in ''
| 369 | doFilter in org.springframework.security.web.FilterChainProxy$VirtualFilterChain
| 109 | invoke . . . . . . . . . . . . in org.springframework.security.web.access.intercept.FilterSecurityInterceptor
| 83 | doFilter in ''
| 381 | doFilter . . . . . . . . . . . in org.springframework.security.web.FilterChainProxy$VirtualFilterChain
| 97 | doFilter in org.springframework.security.web.access.ExceptionTranslationFilter
| 381 | doFilter . . . . . . . . . . . in org.springframework.security.web.FilterChainProxy$VirtualFilterChain
| 78 | doFilter in org.springframework.security.web.authentication.AnonymousAuthenticationFilter
| 381 | doFilter . . . . . . . . . . . in org.springframework.security.web.FilterChainProxy$VirtualFilterChain
| 119 | doFilter in org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter
| 381 | doFilter . . . . . . . . . . . in org.springframework.security.web.FilterChainProxy$VirtualFilterChain
| 54 | doFilter in org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter
| 381 | doFilter . . . . . . . . . . . in org.springframework.security.web.FilterChainProxy$VirtualFilterChain
| 187 | doFilter in org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
| 40 | doFilter . . . . . . . . . . . in org.codehaus.groovy.grails.plugins.springsecurity.RequestHolderAuthenticationFilter
| 381 | doFilter in org.springframework.security.web.FilterChainProxy$VirtualFilterChain
| 79 | doFilter . . . . . . . . . . . in org.codehaus.groovy.grails.plugins.springsecurity.MutableLogoutFilter
| 381 | doFilter in org.springframework.security.web.FilterChainProxy$VirtualFilterChain
| 79 | doFilter . . . . . . . . . . . in org.springframework.security.web.context.SecurityContextPersistenceFilter
| 381 | doFilter in org.springframework.security.web.FilterChainProxy$VirtualFilterChain
| 168 | doFilter . . . . . . . . . . . in org.springframework.security.web.FilterChainProxy
| 346 | invokeDelegate in org.springframework.web.filter.DelegatingFilterProxy
| 259 | doFilter . . . . . . . . . . . in ''
| 243 | internalDoFilter in org.apache.catalina.core.ApplicationFilterChain
| 210 | doFilter . . . . . . . . . . . in ''
| 113 | doFilter in io.jdev.miniprofiler.servlet.ProfilingFilter
| 243 | internalDoFilter . . . . . . . in org.apache.catalina.core.ApplicationFilterChain
| 210 | doFilter in ''
| 69 | doFilterInternal . . . . . . . in org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter
| 76 | doFilter in org.springframework.web.filter.OncePerRequestFilter
| 243 | internalDoFilter . . . . . . . in org.apache.catalina.core.ApplicationFilterChain
| 210 | doFilter in ''
| 66 | doFilterInternal . . . . . . . in org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter
| 76 | doFilter in org.springframework.web.filter.OncePerRequestFilter
| 243 | internalDoFilter . . . . . . . in org.apache.catalina.core.ApplicationFilterChain
| 210 | doFilter in ''
| 88 | doFilterInternal . . . . . . . in org.springframework.web.filter.CharacterEncodingFilter
| 76 | doFilter in org.springframework.web.filter.OncePerRequestFilter
| 346 | invokeDelegate . . . . . . . . in org.springframework.web.filter.DelegatingFilterProxy
| 259 | doFilter in ''
| 243 | internalDoFilter . . . . . . . in org.apache.catalina.core.ApplicationFilterChain
| 210 | doFilter in ''
| 222 | invoke . . . . . . . . . . . . in org.apache.catalina.core.StandardWrapperValve
| 123 | invoke in org.apache.catalina.core.StandardContextValve
| 171 | invoke . . . . . . . . . . . . in org.apache.catalina.core.StandardHostValve
| 99 | invoke in org.apache.catalina.valves.ErrorReportValve
| 118 | invoke . . . . . . . . . . . . in org.apache.catalina.core.StandardEngineValve
| 408 | service in org.apache.catalina.connector.CoyoteAdapter
| 1023 | process . . . . . . . . . . . . in org.apache.coyote.http11.AbstractHttp11Processor
| 589 | process in org.apache.coyote.AbstractProtocol$AbstractConnectionHandler
| 312 | run . . . . . . . . . . . . . . in org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor
| 895 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 918 | run . . . . . . . . . . . . . . in ''
^ 662 | run in java.lang.Thread
Any help would be really appreciated. 任何帮助将非常感激。
I think the problem is because of the way you have named the attributes of the domain class. 我认为问题是由于您为域类的属性命名的方式所致。 Have you tried to do the following?
您是否尝试过以下操作?
class Clients {
String cClientId
String cFirstName
String cSurname
String cEmail
static mapping = {
id name: "cClientId", generator: "assigned"
version false
datasource "dataSourceOld"
cache usage: 'read-only'
}
static constraints = {
cClientId(maxSize: 12)
cFirstName(nullable: true, maxSize: 5)
cSurname(maxSize: 30)
cEmail(maxSize: 30)
}
}
Thus if you declare constraints as follows: 因此,如果您声明约束如下:
static constraints = {
cClientId maxSize: 12
cFirstName nullable: true, maxSize: 5
cSurname maxSize: 30
cEmail maxSize: 30
}
It's works ;) 其作品 ;)
看起来Grails无法将您的客户端识别为域对象,这就是为什么所有GORM动态方法(获取,列出,查找,保存,更新...)都不起作用的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.