我在saving object
IllegalArgumentException occurred while calling setter for property [com.rasvek.cg.entity.AssocClassSubject.assocClassSubjectPKId (expected type = java.lang.Integer)]; target = [com.rasvek.cg.entity.AssocClassSubject@1e254e0], property value = [POST_INSERT_INDICATOR]
at org.hibernate.property.access.spi.SetterMethodImpl.set(SetterMethodImpl.java:99)
at org.hibernate.mapping.Component$ValueGenerationPlan.execute(Component.java:434)
at org.hibernate.id.CompositeNestedGeneratedValueGenerator.generate(CompositeNestedGeneratedValueGenerator.java:97)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:105)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:192)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:177)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:97)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:73)
at org.hibernate.internal.SessionImpl.fireSaveOrUpdate(SessionImpl.java:660)
at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:652)
at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:647)
at com.rasvek.cms.dao.MasterDaoImpl.updateClassSubjectMapping(MasterDaoImpl.java:2074)
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 org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
at com.sun.proxy.$Proxy544.updateClassSubjectMapping(Unknown Source)
at com.rasvek.cms.service.MasterSeviceImpl.updateClassSubjectMapping(MasterSeviceImpl.java:641)
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 org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
at com.sun.proxy.$Proxy545.updateClassSubjectMapping(Unknown Source)
at com.rasvek.cms.controller.MasterController.updateClassSubjectMapping(MasterController.java:1617)
at com.rasvek.cms.controller.MasterController$$FastClassBySpringCGLIB$$c2eff8c2.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
at com.rasvek.cms.controller.MasterController$$EnhancerBySpringCGLIB$$43169cd4.updateClassSubjectMapping(<generated>)
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 org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:883)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:651)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1100)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:687)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
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 org.hibernate.property.access.spi.SetterMethodImpl.set(SetterMethodImpl.java:44)
... 97 more
实际上这个assocClassSubjectPKId
在我的实体类中是整数,即使
它的要求类似于(期望的类型= java.lang.Integer)
请查看我的实体类
@Entity
@Table(name = "assoc_class_subject", catalog = "campus_guru_01")
public class AssocClassSubject implements java.io.Serializable {
private AssocClassSubjectId id;
private MasterCampusClass masterCampusClass;
private MasterSubject masterSubject;
private Integer assocClassSubjectPKId;
public AssocClassSubject() {
}
public AssocClassSubject(AssocClassSubjectId id, MasterCampusClass masterCampusClass, MasterSubject masterSubject) {
this.id = id;
this.masterCampusClass = masterCampusClass;
this.masterSubject = masterSubject;
}
@EmbeddedId
@AttributeOverrides({ @AttributeOverride(name = "classId", column = @Column(name = "class_id", nullable = false)),
@AttributeOverride(name = "subjectId", column = @Column(name = "subject_id", nullable = false)),
@AttributeOverride(name = "subjectOrder", column = @Column(name = "subject_order")),
@AttributeOverride(name = "subjectExclude", column = @Column(name = "subject_exclude", length = 45)) })
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "class_subject_mapping_id", unique = true, nullable = false)
public Integer getAssocClassSubjectPKId() {
return assocClassSubjectPKId;
}
public void setAssocClassSubjectPKId(Integer assocClassSubjectPKId) {
this.assocClassSubjectPKId = assocClassSubjectPKId;
}
public AssocClassSubjectId getId() {
return this.id;
}
public void setId(AssocClassSubjectId id) {
this.id = id;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "class_id", nullable = false, insertable = false, updatable = false)
public MasterCampusClass getMasterCampusClass() {
return this.masterCampusClass;
}
public void setMasterCampusClass(MasterCampusClass masterCampusClass) {
this.masterCampusClass = masterCampusClass;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "subject_id", nullable = false, insertable = false, updatable = false)
public MasterSubject getMasterSubject() {
return this.masterSubject;
}
public void setMasterSubject(MasterSubject masterSubject) {
this.masterSubject = masterSubject;
}
}
为什么它甚至是整数给出这个例外?
我做错了什么?无法追踪它。请帮帮我。 谢谢你!修改
任何人都可以告诉这一行究竟是什么意思
IllegalArgumentException occurred while calling setter for property [com.rasvek.cg.entity.AssocClassSubject.assocClassSubjectPKId(expected type = java.lang.Integer)]; target = [com.rasvek.cg.entity.AssocClassSubject@1aeba13], property value = [POST_INSERT_INDICATOR]
答案 0 :(得分:0)
我通过改变实体类来解决它
package com.rasvek.cg.entity;
// Generated Jun 1, 2018 11:33:12 PM by Hibernate Tools 5.1.7.Final
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
/**
* AssocClassSubject generated by hbm2java
*/
@Entity
@Table(name = "assoc_class_subject", catalog = "campus_guru_01")
public class AssocClassSubject implements java.io.Serializable {
private Integer classSubjectMappingId;
private MasterCampusClass masterCampusClass;
private MasterSubject masterSubject;
private Integer subjectOrder;
private String subjectExclude;
public AssocClassSubject() {
}
public AssocClassSubject(MasterCampusClass masterCampusClass, MasterSubject masterSubject) {
this.masterCampusClass = masterCampusClass;
this.masterSubject = masterSubject;
}
public AssocClassSubject(MasterCampusClass masterCampusClass, MasterSubject masterSubject, Integer subjectOrder,
String subjectExclude) {
this.masterCampusClass = masterCampusClass;
this.masterSubject = masterSubject;
this.subjectOrder = subjectOrder;
this.subjectExclude = subjectExclude;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "class_subject_mapping_id", unique = true, nullable = false)
public Integer getClassSubjectMappingId() {
return this.classSubjectMappingId;
}
public void setClassSubjectMappingId(Integer classSubjectMappingId) {
this.classSubjectMappingId = classSubjectMappingId;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "class_id", nullable = false)
public MasterCampusClass getMasterCampusClass() {
return this.masterCampusClass;
}
public void setMasterCampusClass(MasterCampusClass masterCampusClass) {
this.masterCampusClass = masterCampusClass;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "subject_id", nullable = false)
public MasterSubject getMasterSubject() {
return this.masterSubject;
}
public void setMasterSubject(MasterSubject masterSubject) {
this.masterSubject = masterSubject;
}
@Column(name = "subject_order")
public Integer getSubjectOrder() {
return this.subjectOrder;
}
public void setSubjectOrder(Integer subjectOrder) {
this.subjectOrder = subjectOrder;
}
@Column(name = "subject_exclude", length = 45)
public String getSubjectExclude() {
return this.subjectExclude;
}
public void setSubjectExclude(String subjectExclude) {
this.subjectExclude = subjectExclude;
}
}
谢谢大家!