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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:41:32+00:00 2026-06-15T07:41:32+00:00

We have a Hibernate-based (33.) web application and are finding an issue related to

  • 0

We have a Hibernate-based (33.) web application and are finding an issue related to swapping datavalue pairs restricted by a unique index. In our flightticket HBM we have

<many-to-one name="participants" class="net.umbrella.entity.ParticipantModel" fetch="select">
    <column name="PARTICIPANTID" not-null="false" />
</many-to-one>
<many-to-one name="flights" class="net.umbrella.entity.FlightModel" fetch="select">
    <column name="FLIGHTID" not-null="true" />
</many-to-one>

It is functionally possible to take a data pair with ticket A assigned to participant P1 plus ticket B assigned to participant P2 and swap the two participants. Ticket A would end up assigned to participant P2, ticket B would be assigned to participant P1. However, FLIGHTID + PARTICIPANTID have a unique constraint.

When Hibernate issues the first update to change participant P1 to P2 on ticket A, a GenericJDBCException is thrown

Attempt to insert duplicate key row in object 'FLIGHTTICKET' with unique index 'IDX_FLIGHTTICKET_UQ'

Does anyone have a common solution to this?

Thanks
Simon

  • 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-15T07:41:33+00:00Added an answer on June 15, 2026 at 7:41 am

    So, you have something like this:

    Participant temp = pair1.getParticipant();
    pair1.setParticipant(pair2.getParticipant());
    pair2.setParticipant(temp);
    

    Instead, just do the following:

    Participant temp1 = pair1.getParticipant();
    Participant temp2 = pair2.getParticipant();
    pair2.setParticipant(null);
    session.flush();
    pair1.setParticipant(temp2);
    pair2.setParticipant(temp1);
    

    The intermediate flush will make sure only one pair at a time references a participant.

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

Sidebar

Related Questions

I have web application based on Spring-MVC. I've integrated it with Hibernate 3.6.0. When
I have a Spring MVC based Web Application with Hibernate. Following is the directory
In my java based web application (struts 2 and hibernate 3) . I have
I am using Spring/Hibernate and Spring-Security for my web-based application. Now I have a
We have a Hibernate based system with Annotations. Our entities have a custom property
I am new to Hibernate. I have an exception while running an Hibernate-based application.
I am looking for a web based report designer supporting spring/hibernate. I have seen
I have a web application developed using Java (Java EE), spring & Hibernate. We
I have a spring based webapp that persists data with Hibernate. The default web
The environment of my application: web-based, Spring MVC+Security, Hibernate, MySQL(InnoDB) I am working on

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.