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

  • SEARCH
  • Home
  • 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 8010183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:39:48+00:00 2026-06-04T18:39:48+00:00

I tried many methods on the net, but it doesn’t work. I want to

  • 0

I tried many methods on the net, but it doesn’t work.
I want to delete data from a database using hibernate, but I get this errors
SEVERE: Cannot delete or update a parent row: a foreign key constraint fails (sakila.comanda, CONSTRAINT comanda_ibfk_1 FOREIGN KEY (IDPRODUS) REFERENCES produs (IDPRODUS))
SEVERE: Could not synchronize database state with session

comanda means order and produs means product

Here is the code:

    private void StergeButtonActionPerformed(java.awt.event.ActionEvent evt) {
    try{
        org.hibernate.Transaction tx = session.beginTransaction();

        int idprodus = ((Produs)IdProdusComboBox.getSelectedItem()).getIdprodus();
        Produs produs = (Produs) session.get(Produs.class, idprodus);

        session.delete(produs);

        tx.commit();
    }catch(Exception e){
        System.out.println(e.getMessage());
    }
}
  • 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-04T18:39:50+00:00Added an answer on June 4, 2026 at 6:39 pm

    This just means that deleting the product is impossible, because it would break a foreign key constraint in database. You have orders for your product, but you’re trying to delete the product. How will you honor the orders? You have to decide:

    • either you delete the orders referencing the product before deleting the product
    • or you keep the orders in the database, but these orders must not reference the product anymore.

    Not doing any of the above would leave the database in an inconsistent state: orders for products which don’t exist. The foreign key constraint in the database ensures that such an inconsistent state is impossible.

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

Sidebar

Related Questions

I tried many things but I always get cannot convert string to membershipuser from
The question is pretty much self-explanatory. I Googled many sites, many methods, tried many
I have tried many different languages and copied various examples, but none of my
I've tried many functions already, but I simply can't figure this out. The right
I've tried many variations of this command: idle.py -e filepath , but it simply
This should be really simple, but I have tried many solutions posted on the
I see many applications that uses node runs forever. Therefore, I tried using setInterval
I've tried many versions of the following code in g++ ( version 4.6.3 ).
Ok so this is my first applet, I tried many times to bypass this
I need help to align CSS buttons. I tried many different variations and I

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.