-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Integrity constraint Error - Please help
PostPosted: Sat Apr 05, 2008 8:36 pm 
Beginner
Beginner

Joined: Mon Nov 29, 2004 5:34 pm
Posts: 35
Hi Friends,
I am getting error in my application.

I was developing my application with my local environment with Oracle XE local database and everything works perfectly fine there. But when I deploy application to Test environment I get the integrity constraint error.

Did any of you experience this error, can you suggest any solution. We have compared many times the database and both looks same.
And using the same script to create both database. Do not know, why we are getting this error only in Test Environment.

Quote:
Error - ORA-02291: integrity constraint (schmea.FKB673EFB6D0B27EE) violated - parent key not found

I have read most of the forums and threads and did not find any solution, I have tired all the options I can think of. Please help.


Files,
Parent class –

Code:
public class Batch extends BaseObject
{
  public List<Action> actions;
 
  @OneToMany(mappedBy = "batch", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
  @JoinColumn(name="BATCH_KEY", nullable=false)
  @OrderBy("timestamp DESC")
  public List<Action> getActions()
  {
    if (actions == null)
    {
      actions = new ArrayList();
    }
    return actions;
  }

}


Child class –
Code:
public class Action extends BaseObject
{

  private Batch batch;

  @ManyToOne(cascade =  CascadeType.ALL)
  @JoinColumn(name = "BATCH_KEY", nullable = false)
  public Batch getBatch()
  {
    return batch;
  }
}


Java code to add child to parent table

Code:
public void addAction(Action action)
  {
    if (action == null)
    { // do nothing
      return;
    }
    // tie the action to this batch
    action.setBatch(this);
    this.getActions().add(action);
}


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 06, 2008 4:26 pm 
Beginner
Beginner

Joined: Mon Nov 29, 2004 5:34 pm
Posts: 35
I have found that in the test environment, even though I am trying to save object is not actually getting saved to database.

Any clues.

If I point to my local environment to my local database everything works as I mentioned before but if I am point my local environment to test database, The java objects are not persisted to test database which is on different server.

And I do not see any error. Any clues?

_________________
My Forte 4GL and Spring Blog

srigold


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 07, 2008 2:31 pm 
Beginner
Beginner

Joined: Mon Nov 29, 2004 5:34 pm
Posts: 35
Got it, I have solved the problem,

I was doing different things in one transaction.

1. creating batch
2. Adding action
3. Calling stored procedure
4. Adding action again.

the 4th step was failing because it was calling store procedure.

So for the 3rd step for the stored procedure I have to do -

@Transactional(propagation=Propagation.REQUIRES_NEW) (I was using spring framework)



srigold


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.