DBAsupport.com Forums - Powered by vBulletin
Results 1 to 6 of 6

Thread: ORA-02291: integrity constraint

Hybrid View

  1. #1
    Join Date
    Jun 2008
    Posts
    3

    ORA-02291: integrity constraint

    Hi
    I face this weird problem
    When i save the data from my screen without missing any mandatory details, the value is correctly saved in the DB.
    But when i miss any mandatory fields, i am asked to fill the required details.
    After giving all the details only in this scenario i get the following error:

    ava.sql.BatchUpdateException: ORA-02291: integrity constraint (TL5TEST1.SYS_C0022921) violated - parent key not found

    at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:367)
    at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:8726)
    at weblogic.jdbc.wrapper.PreparedStatement.executeBatch(PreparedStatement.java:137)
    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:230)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListene r.java:296)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1009)
    at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:356)
    at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
    at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager. java:584)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPla tformTransactionManager.java:500)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTr ansactionManager.java:473)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturni ng(TransactionAspectSupport.java:266)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.jav a:106)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java :170)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
    at $Proxy12.saveCompany(Unknown Source)
    at com.elemica.fusion.account.SaveCompanyAction.executeAction(SaveCompanyAction.java:278)
    at com.elemica.util.base.ActionBase.execute(ActionBase.java:88)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:996)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
    at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInVie wFilter.java:174)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java :6458)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3661)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2630)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)




    Thanks for any suggestions in advance

  2. #2
    Join Date
    Mar 2000
    Location
    Atlanta, GA,USA
    Posts
    155
    Welcome to "black box" approach to database development! The truth is you still need to understand how underlaying database is designed.

    Now to the question. The message is clearly pointing on TL5TEST1.SYS_C0022921 foreign key constraint. It is telling you that the parent table it references does not have the primary key value for the record your application is trying to insert into the child table.
    The following query will give you parent table, child table and PK constraint referenced by the FK constraint above:

    select b.table_name parent_table,
    b.constraint_name pk_constraint,
    a.table_name child_table
    from user_constraints a,
    user_constraints b
    where a.constraint_name = 'SYS_C0022921'
    and b.constraint_name = a.r_constraint_name;

    You need to be logged in as the schema owner to run this query. Otherwise you should be looking for the data in all_constraints instead and add predicates for column "owner".

  3. #3
    Join Date
    Jun 2008
    Posts
    3
    Thanks for the reply

    i ran the query and got my Parent table and Child Table with the PK_Constraint.
    pls guide me what should be doin next.i compared the hbm files of both the table and the mapping is correct.i cannot log in as the schema owner due to acess issues.am not able to understand why this problem is coming in one particular scenario and not all insert scenario.

  4. #4
    Join Date
    Mar 2000
    Location
    Atlanta, GA,USA
    Posts
    155
    I cannot help you with analyzing the data in your database. You need to read on integrity constraints to understand them. This will allow you to research your problem and fix it effectively. This is the link to the documentation on integrity constraints and how they work: http://download.oracle.com/docs/cd/B..._int.htm#i6686

    Please, fix your shift key & stop using phone text message style when asking questions.

    Sergey

  5. #5
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    As stated by Sergey this is not a "weird problem", this is an application design issue.

    If Development team is not available, talk to your DBA.
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  6. #6
    Join Date
    Jun 2008
    Posts
    3
    Thank u so much for your help
    The issue is fixed.It was because the value that was getting saved had lot of extra spaces .Now when i trim the value and enter in the DB i dont get any constraint violation.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width