`

Dialect does not support identity key generation

阅读更多
在使用struts2的json部分是遇到这样的一个异常如下:
org.hibernate.MappingException: Dialect does not support identity key generation
	at org.hibernate.dialect.Dialect.getIdentitySelectString(Dialect.java:526)
	at org.hibernate.dialect.Dialect.getIdentitySelectString(Dialect.java:515)
	at org.hibernate.persister.entity.AbstractEntityPersister.getIdentitySelectString(AbstractEntityPersister.java:2163)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:173)
	at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:143)
	at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:113)
	at com.googlecode.jsonplugin.JSONWriter.map(JSONWriter.java:292)
	at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:133)
	at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:113)
	at com.googlecode.jsonplugin.JSONWriter.add(JSONWriter.java:258)
	at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:199)
	at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:143)
	at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:113)
	at com.googlecode.jsonplugin.JSONWriter.add(JSONWriter.java:258)
	at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:199)
	at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:143)
	at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:113)
	at com.googlecode.jsonplugin.JSONWriter.add(JSONWriter.java:258)
	at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:199)
	at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:143)
	at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:113)
	at com.googlecode.jsonplugin.JSONWriter.add(JSONWriter.java:258)
	at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:199)
	at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:143)
	at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:113)
	at com.googlecode.jsonplugin.JSONWriter.add(JSONWriter.java:258)
	at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:199)
	at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:143)
	at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:113)
	at com.googlecode.jsonplugin.JSONWriter.write(JSONWriter.java:81)
	at com.googlecode.jsonplugin.JSONUtil.serialize(JSONUtil.java:62)
	at com.googlecode.jsonplugin.JSONResult.execute(JSONResult.java:117)
	at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:348)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:253)
	at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221)
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
	at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
	at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
	at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150)
	at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48)
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
	at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
	at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
	at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:123)
	at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
	at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
	at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:167)
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
	at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
	at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
	at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:105)
	at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
	at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
	at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:83)
	at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
	at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
	at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:207)
	at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
	at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)

解决方案如下:
这个问题极有可能是由于使用了googlecode的jsonplugin,json是用来实例化bean的;如果action中引用了service,则它也会去试图实例化,这样出错了。方法:可以将service的get方法去掉;或者在其get方法上面加:@JSON(serialize = false)

分享到:
评论
2 楼 abc3720 2012-06-15  
不行的啊 我试了下
1 楼 tourney 2012-05-28  

相关推荐

Global site tag (gtag.js) - Google Analytics