hibernate update方法无效(急)
我的update方法无效 后台输出 Hibernate:
update
Qs_Score
set
exendt=?,
exmstate=?,
extime=?,
qsdate=?,
scmeetw=?,
scmemo=?,
screcept=?,
scrst=?,
strid=?,
wrexam=?
where
scrid=?
当把update改成merge后 报错
Struts Problem Report
Struts has detected an unhandled exception:
Messages:
ORA-00001: ???????? (ERJUAN.SYS_C0011847)
Could not execute JDBC batch update
Could not execute JDBC batch update; SQL [insert into Qs_Score (exendt, exmstate, extime, qsdate, scmeetw, scmemo, screcept, scrst, strid, wrexam, scrid) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
File:oracle/jdbc/driver/DatabaseError.java
Line number:498
package org.oa.dao;
import java.sql.SQLException;
import java.util.List;
import javax.annotation.Resource;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.oa.pojoes.Qs_STRANGER;
import org.oa.pojoes.Qs_Score;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;
import bsh.This;
/**
* 面试信息的操作方法
* @author Administrator
*
*/
@Component(value="ScoreDao")
public class ScoreDaoImpI implements ScoreDaoI
{
private HibernateTemplate hibernateTemplate;
@Resource(name = "sessionFactory")
public void setsessionFactory(SessionFactory sf)
{
this.hibernateTemplate = new HibernateTemplate(sf);
}
public List search(String hql)
{
return this.hibernateTemplate.find(hql);
}
public Object searchBySql(final String sql)
{
// TODO Auto-generated method stub
return this.hibernateTemplate.execute(new HibernateCallback<Object>()
{
public Object doInHibernate(Session session) throws HibernateException, SQLException
{
SQLQuery sqlQuery = session.createSQLQuery(sql);
return sqlQuery.uniqueResult();
}
});
}
public void save(Qs_Score pojo){
this.hibernateTemplate.save(pojo);
}
public void update(Qs_Score pojo)
{
this.hibernateTemplate.update(pojo);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<!-- 支持注解风格的bean配置 -->
<context:annotation-config></context:annotation-config>
<context:component-scan base-package="org.oa.dao"></context:component-scan>
<context:component-scan base-package="org.oa.biz"></context:component-scan>
<context:component-scan base-package="org.oa.web"></context:component-scan>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
</beans>
package org.oa.web.actionss;
import java.math.BigDecimal;
import java.util.List;
import javax.annotation.Resource;
import org.oa.biz.ScoreBiz;
import org.oa.dao.ScoreDaoI;
import org.oa.pojoes.Qs_STRANGER;
import org.oa.pojoes.Qs_Score;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
@Component(value = "SocreAction")
@Scope(value = "prototype")
public class SocreAction extends ActionSupport
{
@Resource(name = "ScoreBiz")
private ScoreBiz scoreBiz;
@Resource(name = "ScoreDao")
private ScoreDaoI scoreDao;
private Qs_STRANGER qsStranger;
private Qs_Score qsScore;
public Qs_STRANGER getQsStranger()
{
return qsStranger;
}
public void setQsStranger(Qs_STRANGER qsStranger)
{
this.qsStranger = qsStranger;
}
public Qs_Score getQsScore()
{
return qsScore;
}
public void setQsScore(Qs_Score qsScore)
{
this.qsScore = qsScore;
}
/*
* 根据姓名 身份证号 电话 查询 如没记录跳到错误界面 有就将它存到上下文中 如有一条就直接跳到显示界面 多条跳到判断界面
*/
public String query() throws Exception
{
List<Qs_STRANGER> qStrangers = this.scoreBiz.search(qsStranger.getStrname(), qsStranger.getPhone(), qsStranger.getIdnumb());
// System.out.println(qStrangers.size());
if (qStrangers.isEmpty())
{
return "to-error";
} else if (qStrangers.size() > 1)
{
ActionContext.getContext().put("strangers", qStrangers);
return "to-check";
} else
{
ActionContext.getContext().put("strangers", qStrangers);
ActionContext.getContext().put("scoredetail", "");
return super.SUCCESS;
}
}
/*
* 根据界面上传过来的strid 将对应的面试人员信息显示在面试信息管理界面
*/
public String scoredispaly() throws Exception
{
String hql = "from Qs_STRANGER where strid='" + qsStranger.getStrid() + "'";
List<Qs_STRANGER> qStrangers = this.scoreDao.search(hql);
ActionContext.getContext().put("strangers", qStrangers);
String hql1 = "from Qs_Score where strid='" + qsStranger.getStrid() + "'";
List<Qs_Score> qsScores = this.scoreDao.search(hql1);
ActionContext.getContext().put("scoredetail", qsScores);
return super.SUCCESS;
}
/*
* 根据界面上传过来的面试人员信息的strid 查出对应的面试信息
*/
public String scoredetail() throws Exception
{
String hql = "from Qs_Score where strid='" + qsStranger.getStrid() + "'";
List<Qs_Score> qsScores = this.scoreDao.search(hql);
ActionContext.getContext().put("scoredetail", qsScores);
return super.SUCCESS;
}
/*
* 取得界面上的面试信息的值 保存到数据库中
*/
public String save() throws Exception
{
//String sql = "select qsdate from Qs_Score where strid='" + qsStranger.getStrid() + "'";
//System.out.println("111111111");
//String qsdatetmp = (String) scoreDao.searchBySql(sql);
System.out.println(qsScore.getQsdate() + "//////////");
System.out.println(qsScore.getScrecept());
//this.scoreDao.update(qsScore);
if (qsScore.getQsdate().equals(""))
{
qsScore.setQsdate(scoreBiz.getSysDate());
qsScore = new Qs_Score(qsStranger.getStrid(), qsScore.getScrid(), qsScore.getQsdate(), qsScore.getScrecept(), qsScore.getWrexam(), qsScore.getScmeetw(), qsScore.getScrst(), qsScore.getScmemo(), qsScore.getExmstate(), qsScore.getExtime(), qsScore.getExendt());
this.scoreDao.save(qsScore);
} else
{ qsScore = new Qs_Score(qsStranger.getStrid(), qsScore.getScrid(), qsScore.getQsdate(), qsScore.getScrecept(), qsScore.getWrexam(), qsScore.getScmeetw(), qsScore.getScrst(), qsScore.getScmemo(), qsScore.getExmstate(), qsScore.getExtime(), qsScore.getExendt());
this.scoreDao.update(qsScore);
}
return this.scoredispaly();
}
}