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 9090139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:18:27+00:00 2026-06-16T22:18:27+00:00

I am currently coding test with dbunit(using hsqldb). However, I have a huge Problem

  • 0

I am currently coding test with dbunit(using hsqldb). However, I have a huge Problem at initializing the db:

here`s the code:

/**
     * Init before a test starts
     */
    @Before
    public void initialise() {
        IDataSet dataSetRating = null;
        IDataSet dataSetMovie = null;

        log.info("enter init test");

        try {
            con = datasource.getConnection();
            icon = new DatabaseConnection(con);
            File rating = new File("./src/test/resources/startDatabaseRating.xml");         
            dataSetRating = new FlatXmlDataSetBuilder().build(rating);
            DatabaseOperation.CLEAN_INSERT.execute(icon, dataSetRating);
        } catch (Exception e) {
            e.printStackTrace();
            log.error(e);
            System.exit(-1);
        }
    }

my create statement looks like that:

CREATE TABLE Rating
(
    rid INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
    mid INTEGER FOREIGN KEY REFERENCES Movie(movieId), 
    rating INTEGER NOT NULL, 
);

and my startDatabaseRating.xml looks like that:

<?xml version="1.0" encoding="UTF-8"?>
<dataset>
    <Rating rid="0" mid="0" rating="1" />
    <Rating rid="1" mid="0" rating="2" />
    <Rating rid="2" mid="0" rating="3" />
    <Rating rid="3" mid="0" rating="4" />

    <Movie movieid="0" title="Movie1" moviePath="C" />
    <Movie movieid="1" title="Movie2" moviePath="D" />
</dataset> 

When I run the tests I get:

java.sql.SQLIntegrityConstraintViolationException: integrity
constraint violation: foreign key no action; SYS_FK_10556 table:
RATING

Why do I get this exception, cause there is still a dataset in the *.xml file. How to fix this problem?

UPDATE:

CREATE TABLE Movie
(
    movieId INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
    title VARCHAR(255) NOT NULL,
    moviePath VARCHAR(500) NOT NULL
);
  • 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-16T22:18:28+00:00Added an answer on June 16, 2026 at 10:18 pm

    When inserting a rating, the movie that is referenced must already exist in the movie table. So you are inserting the rows in the wrong order.

    You need to first insert the movies, then the ratings.

    <?xml version="1.0" encoding="UTF-8"?>
    <dataset>
        <Movie movieid="0" title="Movie1" moviePath="C" />
        <Movie movieid="1" title="Movie2" moviePath="D" />
    
        <Rating rid="0" mid="0" rating="1" />
        <Rating rid="1" mid="0" rating="2" />
        <Rating rid="2" mid="0" rating="3" />
        <Rating rid="3" mid="0" rating="4" />
    </dataset> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently using a JavaScript coding style based on Douglas Crockford's Code Conventions for
I'm currently coding an HTML email, using MailChimp to test it, and eventually to
I am currently coding setup.py using setuptools. And I want to copy the static
I have a minor concern: I'm currently coding a sign up form and I
We're coding a Java6 project under Eclipse Indigo and we currently have some compilations
I'm currently trying to learn WinSock coding from http://johnnie.jerrata.com/winsocktutorial/ however when I compile my
I'm currently working on some coding for a hotel booking widget and am using
I'm coding Settlers of Catan for iOS and currently have my data tiles in
Just a quick question... I currently have the following jQuery code with a selector
Here you can test the website i'm currently working on: http://www.whateverxpress.com/wx_site/ When you navigate

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.