ssh集成关于hibernate问题

sunlucky 2010-03-05 12:49:06
Hibernate: update QMAX_GSM_EX_PLAN_GAGES set EXAMINE_PLAN_ID=null where EXAMINE_PLAN_ID=?
[log4j] [ERROR] org.hibernate.util.JDBCExceptionReporter.logExceptions(JDBCExceptionReporter.java:72) - ORA-01407: 无法更新 ("GSM"."QMAX_GSM_EX_PLAN_GAGES"."EXAMINE_PLAN_ID") 为 NULL

[log4j] [ERROR] org.hibernate.util.JDBCExceptionReporter.logExceptions(JDBCExceptionReporter.java:72) - ORA-01407: 无法更新 ("GSM"."QMAX_GSM_EX_PLAN_GAGES"."EXAMINE_PLAN_ID") 为 NULL

[log4j] [ERROR] org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:301) - Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:249)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
我在删除时报这种异常,请问怎么解决,急!
...全文
125 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
DayDreamer922 2012-04-09
  • 打赏
  • 举报
回复
有外键约束的情况下只能做假删除或者先删除相关联的表数据,再删除这个表数据
geng114 2010-03-05
  • 打赏
  • 举报
回复
EXAMINE_PLAN_ID 字段是否有非空的约束
sunlucky 2010-03-05
  • 打赏
  • 举报
回复
对呀。。他是外键,和另一个表是一对多的关系
soulx 2010-03-05
  • 打赏
  • 举报
回复
EXAMINE_PLAN_ID
LZ的这个字段,不是主键,要不就是有外键约束,或者有非空设置。
sunlucky 2010-03-05
  • 打赏
  • 举报
回复
补充如下:DAO: public void removeObjectByID(Class klass, String systemID)
{
getHibernateTemplate().delete(getObjectByID(klass, systemID));
getHibernateTemplate().flush();
}
public Object getObjectByID(Class klass, String systemID)
{
//Object o = getHibernateTemplate().get(klass, Long.valueOf(systemID));
Object o = getHibernateTemplate().get(klass,Long.valueOf(systemID));
if (null==o)
throw new ObjectRetrievalFailureException(klass, systemID);
else
return o;
}
BIZ如下:public void removeExaminePlans(String examinePlanIDs[])
{
if (examinePlanIDs != null && examinePlanIDs.length != 0)
{
for (int i = 0; i < examinePlanIDs.length; i++)
examineDAO.removeObjectByID(com.norteksoft.qmax.gsm.examine.model.ExaminePlan.class, examinePlanIDs[i]);

}
}
ACTION如下: public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
String examinePlanIDs[] = request.getParameterValues("checkboxNO");
examineBO.removeExaminePlans(examinePlanIDs);
return mapping.findForward("search");
}
我在调试的是DAO里面的getHibernateTemplate().flush();出错了,望各位大侠帮帮忙呀,急
sunlucky 2010-03-05
  • 打赏
  • 举报
回复
锘�<?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.norteksoft.qmax.gsm.examine.model.ExaminePlan"
table="QMAX_GSM_EX_EXAMINE_PLAN"
>

<id
name="examinePlanID"
column="EXAMINE_PLAN_ID"
type="long"
unsaved-value="-1"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-ExaminePlan.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<property
name="createBy"
type="string"
column="CREATE_BY"
length="255"
/>

<property
name="createDate"
type="date"
column="CREATE_DATE"
/>

<property
name="lastModifyBy"
type="string"
column="LAST_MODIFY_BY"
length="255"
/>

<property
name="lastModifyDate"
type="date"
column="LAST_MODIFY_DATE"
/>

<property
name="planMonth"
type="string"
column="PLAN_MONTH"
length="255"
/>

<property
name="planType"
type="string"
column="PLAN_TYPE"
length="255"
/>

<property
name="releaseBy"
type="string"
column="RELEASE_BY"
length="255"
/>

<property
name="releaseDate"
type="date"
column="RELEASE_DATE"
/>

<property
name="attribute1"
type="string"
column="ATTRIBUTE1"
length="255"
/>

<property
name="attribute2"
type="string"
column="ATTRIBUTE2"
length="255"
/>

<property
name="attribute3"
type="string"
column="ATTRIBUTE3"
length="255"
/>

<property
name="attribute4"
type="string"
column="ATTRIBUTE4"
length="255"
/>

<property
name="attribute5"
type="string"
column="ATTRIBUTE5"
length="255"
/>

<property
name="condition"
type="string"
column="CONDITION"
length="255"
/>

<property
name="percentage"
type="string"
column="PERCENTAGE"
length="255"
/>

<set
name="planGagesSet"
lazy="true"
cascade="all-delete-orphan"
sort="unsorted"
>

<key
column="EXAMINE_PLAN_ID"
>
</key>

<one-to-many
class="com.norteksoft.qmax.gsm.examine.model.PlanGages"
/>

</set>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-ExaminePlan.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>
sunlucky 2010-03-05
  • 打赏
  • 举报
回复
是呀。。他是有非空约束
luoxiao3224 2010-03-05
  • 打赏
  • 举报
回复
可能是.hbm.xml的问题,一对多中维护关系交给了哪一方,发.hbm.xml看下

67,515

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧