我有一个grails应用程序在保存期间失败。从域对象保存方法中抛出异常。
是否可以调试并逐步执行元类方法实现?如果没有,调查此类问题的推荐方法是什么?
EDIT 以下是有关我所遇到的具体问题的更多信息:
a different object with the same identifier value was already associated with the session: [package.DomainObject#1]. Stacktrace follows:
Message: a different object with the same identifier value was already associated with the session: [package.DomainObject#1]
Line | Method
->> 638 | checkUniqueness in org.hibernate.engine.StatefulPersistenceContext
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 255 | performSaveOrReplicate in org.codehaus.groovy.grails.orm.hibernate.support.ClosureEventTriggeringInterceptor
| 203 | performSave . . . . . . . . . . in org.hibernate.event.def.AbstractSaveEventListener
| 129 | saveWithGeneratedId in ''
| 210 | saveWithGeneratedOrRequestedId in org.hibernate.event.def.DefaultSaveOrUpdateEventListener
| 195 | entityIsTransient in ''
| 117 | performSaveOrUpdate . . . . . . in ''
| 93 | onSaveOrUpdate in ''
| 108 | onSaveOrUpdate . . . . . . . . in org.codehaus.groovy.grails.orm.hibernate.support.ClosureEventTriggeringInterceptor
| 685 | fireSaveOrUpdate in org.hibernate.impl.SessionImpl
| 677 | saveOrUpdate . . . . . . . . . in ''
| 673 | saveOrUpdate in ''
| 58 | doInHibernate . . . . . . . . . in org.codehaus.groovy.grails.orm.hibernate.metaclass.SavePersistentMethod$1
| 406 | doExecute in org.springframework.orm.hibernate3.HibernateTemplate
| 339 | execute . . . . . . . . . . . . in ''
| 56 | performSave in org.codehaus.groovy.grails.orm.hibernate.metaclass.SavePersistentMethod
| 215 | doInvokeInternal . . . . . . . in org.codehaus.groovy.grails.orm.hibernate.metaclass.AbstractSavePersistentMethod
| 63 | invoke in org.codehaus.groovy.grails.orm.hibernate.metaclass.AbstractDynamicPersistentMethod
| -2 | invoke0 . . . . . . . . . . . . in sun.reflect.NativeMethodAccessorImpl
| 57 | invoke in ''
| 43 | invoke . . . . . . . . . . . . in sun.reflect.DelegatingMethodAccessorImpl
| 601 | invoke in java.lang.reflect.Method
| 1243 | jlrMethodInvoke . . . . . . . . in org.springsource.loaded.ri.ReflectiveInterceptor
| 189 | invoke in org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSite
| 53 | call . . . . . . . . . . . . . in org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite
| 45 | defaultCall in org.codehaus.groovy.runtime.callsite.CallSiteArray
| 55 | call . . . . . . . . . . . . . in org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite
| 124 | call in org.codehaus.groovy.runtime.callsite.AbstractCallSite
| 911 | save . . . . . . . . . . . . . in org.codehaus.groovy.grails.orm.hibernate.HibernateGormInstanceApi
| -1 | save in package.DomainObject
控制器中调用的代码是:
def save() {
def domainInstance = new DomainObject(params)
if (!domainInstance.save(flush: true)) { //<!-- Fails here
render(view: "create", model: [domainInstance: DomainObject])
return
}
atachUploadedFilesTo(domainInstance)
flash.message = message(code: 'default.created.message', args: [message(code: 'domainObject.label', default: 'DomainObject'), domainInstance.id])
redirect(action: "show", id: domainInstance.id)
}
在调用save时,数据库中不存在新实例。它表明在某处保存被调用两次,因此我想调试它。