hibernate 異常

Hibernate 拋出異常為:
對數據庫插入記錄時 拋出異常(hibernate 3.0):
Hibernate: insert into LATENT_COMPANY (F_ID, F_NAMEC, F_SNAME, F_TNO, EXPLAIN, F_EXPLAIN, F_REPLC, CONTACT, TITLE, F_TEL, MOBILE, F_FAX, E_MAIL, F_ADDRC, F_POST, F_ADDR, F_URL, ITEM_SCRPTC, CREATE_DATE, IS_DISABLE, CREATOR, BASE_ID, F_REPPROD, PARK_ID, LEVEL_ID, F_KIND, NO_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
16:54:50,218  WARN JDBCExceptionReporter:71 - SQL Error: 1401, SQLState: 23000
16:54:50,218 ERROR JDBCExceptionReporter:72 - ORA-01401: 插入的值对于列过大

16:54:50,218  WARN JDBCExceptionReporter:71 - SQL Error: 1401, SQLState: 23000
16:54:50,218 ERROR JDBCExceptionReporter:72 - ORA-01401: 插入的值对于列过大

16:54:50,234 ERROR AbstractFlushingEventListener:300 - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
    at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
    at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
    at com.cavell.frameworkx.transaction.TransactionManager.commitTransaction(TransactionManager.java:38)
    at com.cavell.frameworkx.action.BaseAction.execute(BaseAction.java:65)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:199)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:145)
    at com.cavell.frameworkx.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:75)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:165)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:145)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:139)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2460)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:119)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955)
    at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:157)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
    at java.lang.Thread.run(Thread.java:534)
Caused by: java.sql.BatchUpdateException: ORA-01401: 插入的值对于列过大

    at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
    at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10656)
    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
    ... 48 more
16:54:50,234  WARN RequestProcessor:538 - Unhandled Exception thrown: class org.hibernate.exception.ConstraintViolationException

LatentCompanyhbm.xml:
<hibernate-mapping package="com.axtronics.pcm.bean"><class>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="com.axtronics.pcm.bean">
<hibernate-mapping package="com.axtronics.pcm.bean">
    <class
        name="LatentCompany"
        table="LATENT_COMPANY"
    >
        <meta attribute="sync-DAO">false</meta>
        <id
            name="Id"
            type="integer"
            column="NO_ID"
        >
            <generator class="sequence">
            <param name="sequence">OBJECT_UNIQUE_ID</param>
            </generator>
       </id><class><id><generator class="sequence"></generator>
       </id><id><generator class="sequence"></generator>
  </id>
        < <property>
            name="FId"
            column="F_ID"
            type="string"
            not-null="true"
            length="10"
        />
        <property>
            name="FNamec"
            column="F_NAMEC"
            type="string"
            not-null="true"
            length="50"
        />
        <property>
            name="FSname"
            column="F_SNAME"
            type="string"
            not-null="true"
            length="20"
        />
        <property>
            name="FTno"
            column="F_TNO"
            type="string"
            not-null="true"
            length="8"
        />
        <property>
            name="Explain"
            column="EXPLAIN"
            type="string"
            not-null="false"
            length="50"
        />
        <property>
            name="FExplain"
            column="F_EXPLAIN"
            type="string"
            not-null="false"
            length="50"
        />
        <property>
            name="FReplc"
            column="F_REPLC"
            type="string"
            not-null="true"
            length="20"
        />
        <property>
            name="Contact"
            column="CONTACT"
            type="string"
            not-null="true"
            length="20"
        />
        <property>
            name="Title"
            column="TITLE"
            type="string"
            not-null="true"
            length="20"
        />
        <property>
            name="FTel"
            column="F_TEL"
            type="string"
            not-null="true"
            length="20"
        />
        <property>
            name="Mobile"
            column="MOBILE"
            type="string"
            not-null="false"
            length="20"
        />
        <property>
            name="FFax"
            column="F_FAX"
            type="string"
            not-null="false"
            length="20"
        />
        <property>
            name="EMail"
            column="E_MAIL"
            type="string"
            not-null="false"
            length="50"
        />
        <property>
            name="FAddrc"
            column="F_ADDRC"
            type="string"
            not-null="true"
            length="100"
        />
        <property>
            name="FPost"
            column="F_POST"
            type="string"
            not-null="true"
            length="10"
        />
        <property>
            name="FAddr"
            column="F_ADDR"
            type="string"
            not-null="false"
            length="100"
        />
        <property>
            name="FUrl"
            column="F_URL"
            type="string"
            not-null="false"
            length="100"
        />
        <property>
            name="ItemScrptc"
            column="ITEM_SCRPTC"
            type="string"
            not-null="true"
            length="512"
        />
        <property>
            name="CreateDate"
            column="CREATE_DATE"
            type="timestamp"
            not-null="true"
            length="23"
        />
        <property>
            name="Disable"
            column="IS_DISABLE"
            type="true_false"
            not-null="false"
            length="1"
        />
        <property>
            name="Creator"
            column="CREATOR"
            type="string"
            not-null="true"
            length="50"
        />
        <many-to-one>
            name="Base"
            column="BASE_ID"
            class="Base"
            not-null="true"
        >
        </many-to-one>
        <many-to-one>
            name="FRepprod"
            column="F_REPPROD"
            class="IndustrySub"
            not-null="true"
        >
        </many-to-one>
        <many-to-one>
            name="Park"
            column="PARK_ID"
            class="Park"
            not-null="true"
        >
        </many-to-one>
        <many-to-one>
            name="Level"
            column="LEVEL_ID"
            class="CompanyLevel"
            not-null="true"
        >
        </many-to-one>
        <many-to-one>
            name="FKind"
            column="F_KIND"
            class="Industry"
            not-null="true"
        >
       </many-to-one><key column="F_ID">
java 代碼:

public ActionForward save(final ActionMapping mapping, final ActionForm form,
            final HttpServletRequest request, final HttpServletResponse response) {
        LatentCompanySrv latentCompanySrv = new LatentCompanySrv();
        LatentCompanyForm aform = (LatentCompanyForm)form;
        LatentCompany latentCompany = null;
       
        int id = 0;
        if (request.getParameter("id") != null) {
            id = Integer.parseInt(request.getParameter("id"));
        }
       
        if (id > 0) {
            latentCompany = (LatentCompany)latentCompanySrv.find(LatentCompany.class, new Integer(id));
        } else {
            latentCompany =  new LatentCompany();

        }
       
        latentCompany = (LatentCompany)LatentCompanyHelp.convert2Bean(aform);
        String userId = request.getParameter("userId");
       
        //waiting for request document.
        if (userId != null && !"".equals(userId.trim())) {
            latentCompany.setCreator(userId);
        } else latentCompany.setCreator("admin");
       
        latentCompanySrv.saveOrUpdate(latentCompany);
        return mapping.findForward("add");
    }

public static Object convert2Bean(LatentCompanyForm aform) {
        LatentCompany latentCompany = new LatentCompany();
        LatentCompanySrv latentCompanySrv = new LatentCompanySrv();
        latentCompany.setCreateDate(new java.util.Date());
       
        //auto create....the FId and FTno,should to modify....
        latentCompany.setFTno(aform.getFtno());
        latentCompany.setFId(aform.getFid());
       
        latentCompany.setFNamec(aform.getFnamec());
        latentCompany.setFSname(aform.getFsname());
        latentCompany.setFReplc(aform.getFreplc());
        latentCompany.setContact(aform.getContact());
        latentCompany.setTitle(aform.getTitle());
        latentCompany.setFTel(aform.getFtel());
        latentCompany.setMobile(aform.getMobile());
        latentCompany.setFFax(aform.getFfax());
        latentCompany.setEMail(aform.getEmail());
        latentCompany.setFAddrc(aform.getFaddrc());
        latentCompany.setFAddr(aform.getFaddr());
        latentCompany.setFPost(aform.getFpost());
        latentCompany.setFUrl(aform.getFurl());
        latentCompany.setItemScrptc(aform.getItemScrptc());
       
        String baseId = aform.getBaseId();
        String parkId = aform.getParkId();
        String indId = aform.getIndId();
        String subId = aform.getSubId();
        String levelId = aform.getLevelId();
       

        latentCompany.setBase((Base)latentCompanySrv.getBase(baseId));
        latentCompany.setPark((Park)latentCompanySrv.getPark(parkId));
        latentCompany.setFKind((</key> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </class>Industry<hibernate-mapping package="com.axtronics.pcm.bean"><class> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property><key column="F_ID">)latentCompanySrv.getIndustry(indId));
        latentCompany.setFRepprod((I</key></property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </class></hibernate-mapping>ndustrySub<hibernate-mapping package="com.axtronics.pcm.bean"><class> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property> <property><key column="F_ID">)latentCompanySrv.getIndustrySub(subId));
        latentCompany.setLevel((CompanyLevel)latentCompanySrv.getCompanyLevel(levelId));

        return latentCompany;
    }</key></property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </property> </class></hibernate-mapping></hibernate-mapping></class></hibernate-mapping>

你可能感兴趣的:(java,Hibernate,servlet,jdbc,IBM)