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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:08:23+00:00 2026-05-23T14:08:23+00:00

In my JPA Entity class I have: @Entity public class Booking { @Id @SequenceGenerator(name

  • 0

In my JPA Entity class I have:

@Entity
public class Booking {
@Id
@SequenceGenerator(name = "BOOKING", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "BOOKING")
private Integer id;

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(nullable = false)
private User user;

// ...
}

In my GWT View I have:

    MainRequestFactory.BookingRequest bookingRequest = reqFactory.bookingRequest();
    BookingProxy bookingProxy = bookingRequest.create(BookingProxy.class);
    UserProxy userProxy = bookingRequest.create(UserProxy.class);

    userProxy.setId(12);

    bookingProxy.setUser(userProxy);

    Request<Void> persistRequest = bookingRequest.persist().using(bookingProxy);
    persistRequest.fire(new Receiver<Void>() {
        @Override
        public void onSuccess(Void response) {
            GWT.log("persisted");
        }
    });

/////////////////////

Users and Bookings persistence without the User Constraint works fine. But with the above code I want/have to assign the user with the ID “12” to a newly created booking. But I cannot assign a new booking to an already existing user ID 12. I get the following error:

[EL Warning]: 2011-07-05
18:48:45.464–UnitOfWork(267787945)–Exception
[EclipseLink-4002] (Eclipse
Persistence Services –
2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception:
org.firebirdsql.jdbc.FBSQLException:
GDS Exception. 335544665. violation of
PRIMARY or UNIQUE KEY constraint
“INTEG_388” on table “USERS2”

It’s because an user with the ID “12” already exists and JPA wants to create a new user with the same ID instead of just creating a new booking with the user ID “12” as its foreign key.

How can I tell RequestFactory NOT to create a new user but instead just to assign the user ID of an already existing user to a new booking entry?

  • 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-05-23T14:08:24+00:00Added an answer on May 23, 2026 at 2:08 pm

    I think your analysis of the problem is correct.

    Instead of creating a User, instead use an EntityManager find() or getReference() to retrieve the existing User item.

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

Sidebar

Related Questions

I have two JPA entities: @Entity public class TaskSchedule { ... private String name;
I have a JPA entity similar to; public class Inventory { private String productname;
I have mapped class in JPA. : @Entity @Inheritance(strategy = InheritanceType.JOINED) public class User
Say I have this class: @Entity @Table(name=PICTURE) public class Picture{ private String category1, category2;
I have an JPA entity like this: @Entity @Table(name = category) public class Category
I have a problem with JPA 1.0 (OpenJPA) Following situation @Entity public class A{
I have the following class (which is a JPA entity listener): @Service public class
I have a domain object class User (it is a JPA entity): @Entity public
A typical JPA entity looks like: @Entity public class Person { @Id private int
Simple JPA/JPQL question. I have an entity with a ManyToMany relationship: @Entity public class

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.