Code Bye

ssh中用hibernate模板update更新问题

Struts Problem Report

Struts has detected an unhandled exception:
Messages: 

    ?????????
    could not update: [com.shop.dao.model.Customer#31]
    could not update: [com.shop.dao.model.Customer#31]; nested exception is org.hibernate.exception.SQLGrammarException: could not update: [com.shop.dao.model.Customer#31]

File:  com/microsoft/sqlserver/jdbc/SQLServerException.java
Line number:  197
Stacktraces
org.springframework.dao.InvalidDataAccessResourceUsageException: could not update: [com.shop.dao.model.Customer#31]; nested exception is org.hibernate.exception.SQLGrammarException: could not update: [com.shop.dao.model.Customer#31]

    org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:615)
    org.springframework.orm.hibernate3.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:789)
    org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:663)
    org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:709)
    org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:678)
    org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:321)
    org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    $Proxy0.update(Unknown Source)
    com.shop.struts.action.CustomerAction.updateList(CustomerAction.java:168)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)
    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)
    

 org.hibernate.exception.SQLGrammarException: could not update: [com.shop.dao.model.Customer#31]

    org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
    org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2596)
    org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2478)
    org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2805)
    org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:114)
    org.hibernate.engine.ActionQueue.execute(ActionQueue.java:267)
    org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:259)
    org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:179)
    org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
    org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
    org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
    org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)
    org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
    org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:655)
    org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:709)
    org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:678)
    org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:321)
    org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    $Proxy0.update(Unknown Source)
    com.shop.struts.action.CustomerAction.updateList(CustomerAction.java:168)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)
    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)
    org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
    org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879)
    org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:617)
    org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1774)
    java.lang.Thread.run(Thread.java:619)
  

 com.microsoft.sqlserver.jdbc.SQLServerException: ?????????

    com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:197)
    com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1493)
    com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:390)
    com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:340)
    com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4575)
    com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1400)
    com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:179)
    com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:154)
    com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:308)
    org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:46)
    org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2574)
    org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2478)
    org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2805)
    org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:114)
    org.hibernate.engine.ActionQueue.execute(ActionQueue.java:267)
    org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:259)
    org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:179)
    org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
    org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
    org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
    org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)
    org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
    org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:655)
    org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:709)
    org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:678)
    org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:321)
    org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    $Proxy0.update(Unknown Source)
    com.shop.struts.action.CustomerAction.updateList(CustomerAction.java:168)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)
    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)
    org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
    org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879)
    org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:617)
    org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1774)
    java.lang.Thread.run(Thread.java:619)
    

You are seeing this page because development mode is enabled. Development mode, or devMode, enables extra debugging behaviors and reports to assist developers. To disable this mode, set:

  struts.devMode=false

in your WEB-INF/classes/struts.properties file.


20分
org.hibernate.exception.SQLGrammarException: could not update看到这一个,一般来说是sql语法有问题,贴代码出来看看
我告诉你啊,这问题真是坑,这项目是老师给的,他给的数据库,我们备份到数据库里的,写映射的时候有个时间戳类型,这玩意不能更新,也不能增加,也就是updae=”false“ insert=”false” 就是说在这里必须在hibernate里设置一下 因为我用的hibernate模板的update函数 不是自己写的hql 所以一时间没有通过这错误看出来 其实这错误就是说在你进行更新的时候 它默认给你全部更新了 比如 你传了一个model到update里,update(cu),明白我意思了吧。
对于以上问题我已近解决了,明天在详细的总结一下,坑爹的时间戳类型,实际上是我旁边的那个比我学的块的把在他调完之后,配置文件里 小小的改了一下 不过现在也知道是咋回事了。对于这种人,严重的鄙视。

20分

确实 ,这中问题有点恶心人

总结下昨天的,表示晚上才有空,白天满课的说。
副代码:
package com.shop.dao.model;

public class Customer {
@SuppressWarnings(“unused”)
private static final long serialVersionUID = 1L;
private Long id;
private String name;
private String password;
private String realName;
private String phone;
private String email;
private String address;
private String zipCode; // 12
private String datetime;

public void setDatetime(String datetime) {
this.datetime = datetime;
}

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getRealName() {
return realName;
}

public void setRealName(String realName) {
this.realName = realName;
}

public String getPhone() {
return phone;
}

public void setPhone(String phone) {
this.phone = phone;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

public String getDatetime() {
return datetime;
}

public String getZipCode() {
return zipCode;
}

public void setZipCode(String zipCode) {
this.zipCode = zipCode;
}

}
customer.hbm.xml:hibernate配置文件
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE hibernate-mapping PUBLIC “-//Hibernate/Hibernate Mapping DTD 3.0//EN” “http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd” >
<hibernate-mapping>
<class name=”com.shop.dao.model.Customer” table=”bs_customer”>
<id name=”id” type=”long”>
<column name=”cust_id”></column>
<generator class=”native” />
</id>
<property name=”datetime” type=”string” insert=”false” update=”false”>
<column name=”cust_datetime” />
</property>
<property name=”name” type=”string”>
<column name=”cust_name”></column>
</property>
<property name=”password” type=”string”>
<column name=”cust_password”></column>
</property>
<property name=”realName” type=”string”>
<column name=”cust_realName”></column>
</property>
<property name=”phone” type=”string”>
<column name=”cust_phone”></column>
</property>
<property name=”email” type=”string”>
<column name=”cust_email”></column>
</property>
<property name=”address” type=”string”>
<column name=”cust_address”></column>
</property>
<property name=”zipCode” type=”string”>
<column name=”cust_zipCode”></column>
</property>
</class>

</hibernate-mapping>
DAO层:
package com.shop.dao;

import java.io.Serializable;
import java.util.List;

import com.shop.dao.model.Customer;

/*
 * 用户管理
 用户登录 提供用户名/密码/验证码后可以登录系统  login
 用户注册 填写详细资料后成为正式注册用户 save
 用户资料修改 用户登录后可以修改自己的注册资料 update
 用户密码找回 忘记密码的用户可以通过email找回密码 no
 //findByName  用于注册验证
 * */
public interface CustomerDao {

public void save(Customer cu);

public void delete(Customer cu);

public void update(Customer cu);

public Customer get(Serializable id);

public List<Customer> list();

public Customer login(String name, String password);

public boolean findByName(String name);
}
DAOImpl层:
package com.shop.dao;

import java.io.Serializable;
import java.util.List;

import com.shop.dao.model.Customer;

/*
 * 用户管理
 用户登录 提供用户名/密码/验证码后可以登录系统  login
 用户注册 填写详细资料后成为正式注册用户 save
 用户资料修改 用户登录后可以修改自己的注册资料 update
 用户密码找回 忘记密码的用户可以通过email找回密码 no
 //findByName  用于注册验证
 * */
public interface CustomerDao {

public void save(Customer cu);

public void delete(Customer cu);

public void update(Customer cu);

public Customer get(Serializable id);

public List<Customer> list();

public Customer login(String name, String password);

public boolean findByName(String name);
}
Service层:
package com.shop.service;

import java.io.Serializable;
import java.util.List;

import com.shop.dao.model.Customer;

public interface CustomerService {
public boolean saveRegister(Customer cu);

public void update(Customer cu);

public Customer get(Serializable id);

public List<Customer> list();

public void delete(Customer cu);

public Customer Login(String name, String password);
}
ServiceImpl层:
package com.shop.service;

import java.io.Serializable;
import java.util.List;

import com.shop.dao.model.Customer;

public interface CustomerService {
public boolean saveRegister(Customer cu);

public void update(Customer cu);

public Customer get(Serializable id);

public List<Customer> list();

public void delete(Customer cu);

public Customer Login(String name, String password);
}
Action:
package com.shop.service;

import java.io.Serializable;
import java.util.List;

import com.shop.dao.model.Customer;

public interface CustomerService {
public boolean saveRegister(Customer cu);

public void update(Customer cu);

public Customer get(Serializable id);

public List<Customer> list();

public void delete(Customer cu);

public Customer Login(String name, String password);
}
Action:
@SuppressWarnings({ “rawtypes”, “unchecked” })
public String updateList() throws Exception{
Map attibutes = ActionContext.getContext().getSession();
Long i = 31L;
attibutes.put(“CustomerUpdate”,service.get(i));
//System.out.println(getId());
cu1 = (Customer)attibutes.get(“CustomerUpdate”);
cu1.setName(getName());
/*cu1.setPassword(getPassword());*/
cu1.setAddress(getAddress());
cu1.setEmail(getEmail());
cu1.setRealName(getRealName());
cu1.setPhone(getPhone());
//cu1.setZipCode(getZipcode());
service.update(getCu1());
return SUCCESS;
}
JSP;
<%@ page language=”java” import=”java.util.*” pageEncoding=”utf-8″%>
<%@ taglib uri=”/struts-tags” prefix=”s”%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+”://”+request.getServerName()+”:”+request.getServerPort()+path+”/”;
%>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
  <head>
    <base href=”<%=basePath%>”>
    <title> 注册 </title>
    <link rel=”stylesheet” type=”text/css” href=”jsp/images/zhuce.css”>
    
<meta http-equiv=”pragma” content=”no-cache”>
<meta http-equiv=”cache-control” content=”no-cache”>
<meta http-equiv=”expires” content=”0″>    
<meta http-equiv=”keywords” content=”keyword1,keyword2,keyword3″>
<meta http-equiv=”description” content=”This is my page”>
  </head>
  <body>
    <div id=”header”>
<div class=”h1″>
<div class=”logo”>
<div class=”tu”><img src=”jsp/images/l1.png”/></div>
<div class=”text”><span>宅猫购物</span></div>
</div>
<div class=”search”>
<form>
<input class=”text” type=”text”></input>
<input class=”submit” type=”submit” value=”快速搜索”></input>
</form>
</div>
</div>
<div class=”h2″>
<ul>
<li><a href=”jsp/main.jsp”>首页</a></li>
<li><a href=”#”>订购</a></li>
<li><a href=”#”>购物车</a></li>
<li><a href=”#”>服务台</a></li>
</ul>
</div>
</div>
<div id=”main”>
<div id=”left”>
         <div class=”regist”>
             <div class=”top”>
                 <ul class=”total”>
                     <li class=”person”>普通会员</li>
                    </ul>
                </div>
                  <div class=”leg” style=”background-color:”>
                   <s:form action=”customerUpdate!updateList”>
                 <table align=”center”>
                  <tr>
                   <td>
                    <s:hidden name=”id” /> 
                   </td>
                   <td> 
                    <s:textfield  name=”name” label=”~昵称 Nickname ”  style=”color:gray;” onMouseOver=”this.style.border=””1px solid #F90″”” onMouseOut=”this.style.border=””1px solid #dddddd”””/>  
                   </td>
                   <td>
                    <s:textfield  name=”realName” label=”~姓名 Name ”  style=”color:gray;” onMouseOver=”this.style.border=””1px solid #F90″”” onMouseOut=”this.style.border=””1px solid #dddddd”””/>  
                   </td>
                    <s:textfield  name=”phone” label=”~电话 Tel ”  style=”color:gray;” onMouseOver=”this.style.border=””1px solid #F90″”” onMouseOut=”this.style.border=””1px solid #dddddd”””/>  
                   <td>
                    <s:textfield  name=”email” label=”~邮箱 Email ”  style=”color:gray;” onMouseOver=”this.style.border=””1px solid #F90″”” onMouseOut=”this.style.border=””1px solid #dddddd”””/>  
                   </td>
                    <s:textfield  name=”zipcode” label=”~邮编 Code ”  style=”color:gray;” onMouseOver=”this.style.border=””1px solid #F90″”” onMouseOut=”this.style.border=””1px solid #dddddd”””/>  
                   <td>
                    <s:textfield  name=”address” label=”~地址 Address ”  style=”color:gray;” onMouseOver=”this.style.border=””1px solid #F90″”” onMouseOut=”this.style.border=””1px solid #dddddd”””/> 
                   </td>
                  </tr>
                 </table> 
                 <center>
                 <input type=”submit” value=”修改”/>
                 </center>
                   </s:form>
                </div>
            </div>
</div>
<div id=”right”>
<div class=”r1″>
<div class=”r11″>最新公告</div>
<ul>
<li><a href=”#”>·我愿生命从容:沈奇岚宅猫独家签名本</a></li>
<li><a href=”#”>·百年老社满减钜惠满100-20 200-50</a></li>
<li><a href=”#”>·经典好书100减40 200减80 300减120</a></li>
</ul>
</div>
<div class=”r2″>
    <div class=”r21″>其他商品</div>
<ul>
<li>
<a href=”#”>
<img src=”jsp/images/10.png” style=”border:1px solid black;”/>
<p>长歌行6</p>
<p>夏达  著</p>
<p>¥9.90</p>
</a>
</li>
<li>
<a href=”#”>
<img src=”jsp/images/11.png” style=”border:1px solid black;”/>
<p>父与子全集</p>
<p>(德)卜劳恩  著</p>
<p>¥17.00</p>
</a>


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明ssh中用hibernate模板update更新问题