Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7942547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:00:19+00:00 2026-06-04T00:00:19+00:00

According to the DBUnit docs link it should support using a CLEAN_INSERT when using

  • 0

According to the DBUnit docs link it should support using a CLEAN_INSERT when using a DatabaseSequenceFilter.

I get the following exception when attempting this

com.sybase.jdbc2.jdbc.SybSQLException: Dependent foreign key constraint violation in a referential integrity constraint. dbname =  'my_db', table name = 'tbl_child', constraint name = 'fk_tbl_child_parentid'.

My tables look like this:

CREATE TABLE dbo.tbl_parent
(
    parent_id            numeric(19,0) IDENTITY,
    ...
)

CREATE TABLE dbo.tbl_child
(
    child_id            numeric(19,0) IDENTITY,
    parent_id           numeric(19,0) NOT NULL,
    ...
)

ALTER TABLE dbo.tbl_child
    ADD CONSTRAINT fk_tbl_child_parentid
    FOREIGN KEY (parent_id)
    REFERENCES dbo.tbl_parent (parent_id)

And my DBUnit dataset looks like this:

<dataset>
  <tbl_parent parent_id="41" ... />

  <tbl_child child_id="1361" parent_id="41"/>
</dataset>

So within my test class where I have this code I get the error if data already exists in the database and it cannot be removed because of the foreign key constraints

@Before 
public void setUp() throws Exception {
    InsertIdentityOperation.CLEAN_INSERT.execute(getConnection(), getDataSet());
}

Interestingly a work around is to use REFRESH instead of CLEAN_INSERT but this is less than ideal because junk data could reside in the database causing side effects:

@Before 
public void setUp() throws Exception {
    InsertIdentityOperation.REFRESH.execute(getConnection(), getDataSet());
}

Has anyone been able to get this CLEAN_INSERT to work with Sybase and foreign keys? From reading other posts similar issues exist for MySQL so maybe there is a common issue here (or me not understanding something)

[EDIT]

I have now added my own workaround answer after running into the same problem again.

I am using Sybase ASE 15 + DBUnit 2.4.8

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:00:21+00:00Added an answer on June 4, 2026 at 12:00 am

    I have come to the conclusion that this is indeed a problem with Sybase + DBUnit after hitting the same issues on another project (although I am using the same JAR file versions and database server).

    The workaround I finally settled on was the following

    @Before 
    public void setUp() throws Exception {
        InsertIdentityOperation.TRUNCATE_TABLE.execute(getConnection(), getDataSet());
        InsertIdentityOperation.INSERT.execute(getConnection(), getDataSet());
    }
    

    The caveat is that the TRUNCATE will obviously blow away all data in the database tables when the test runs, but this is something I can live with. At least I know for certain what data is in the database and my tests are less likely to fail due to erroneous records being inserted by other developers running in between test executions. Probably a good reason why you want a dedicated database for unit + integration tests.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to http://msdn.microsoft.com/en-us/library/ms535934(v=VS.85).aspx and http://msdn.microsoft.com/en-us/library/ms535262(v=VS.85).aspx , I should be able to do the following
According to http://caniuse.com/script-defer , most browsers support the script tag's defer attribute. I would
According to https://developers.google.com/fusiontables/docs/developers_reference OR operations are not allowed as part of filter conditions. So
According to JavaScript Patterns book (p. 79), this should work: var ob = {
According to this post , I am using a data context per call, so
According to this: Get current date/time in seconds var seconds = new Date().getTime() /
According to http://www.bennadel.com/blog/1892-You-Cannot-Bind-The-Submit-Event-To-Objects-Using-jQuery.htm It is a bug: I am pretty sure this is a
According to the documentation i would like to overwrite predefined formats using this settings:
According to the docs: http://msdn.microsoft.com/en-us/library/x13ttww7.aspx : The volatile keyword can be applied to reference
According to author's post in version 2.0 http://lostechies.com/jimmybogard/2011/09/29/automapper-2-0-nestedchild-containers/ but this test doesnt work, can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.