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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:30:50+00:00 2026-05-19T00:30:50+00:00

To my understanding a Unidirectional one-to-many relationship has a join table and a Bidirectional

  • 0

To my understanding a Unidirectional one-to-many relationship has a join table and a Bidirectional one-to-many relationship hasn’t.

My application works when I implemented the Unidirectional relationship but I can’t seem to get it to work for the bidirectional relationship.

These are the tables I am creating

CREATE TABLE CUSTOMER (customerNo INTEGER PRIMARY KEY, joinDate DATE, customerName VARCHAR2(20));

CREATE TABLE BOOKING (bookingNo INTEGER PRIMARY KEY, bookedDate DATE, custNo INTEGER, itemNo NUMBER(10), itemName VARCHAR2(20), quantity NUMBER(5), bookingDate DATE, bookingValue NUMBER(8, 2), constraint booking_fk foreign key (custNo) references customer(customerNo));

My first class

  public class Booking implementes Serializable{
  private Timestamp bookeddate;
      private Timestamp bookingdate;

  @Id()
   @GeneratedValue(generator"MY_SEQ_GEN")
   @SequenceGenerator(name="MY_SEQ_GEN", sequenceName="MY_SEQUENCE", allocationSize=1)
   @Column(name="bookingNo", nullable=false)
  private Long bookingno;
  private Double bookingvalue;

  @Column(length = 20)
  private String itemname;
  private Long itemno;
  private Long quantity;

  private Customer customer;

  @ManyToOne
  public Customer getCustomer() {
    return customer;
  }

  ...

my other class

  public class Customer implements Serializable {
  @Column(length = 20)
  private String customername;
  @Id()
     @GeneratedValue(generator="THE_SEQ_GEN")
     @SequenceGenerator(name="THE_SEQ_GEN", sequenceName="THE_SEQUENCE", allocationSize=1)
     @Column(name="customerNo", nullable=false)
  private Long customerno;
  private Timestamp joindate;

  @OneToMany(cascade=(CascadeType.ALL), fetch=FetchType.EAGER, mappedBy = "customer")
  private List<Booking> bookings = new ArrayList<Booking>();

  public List<Booking> getBookings() {
      return bookings;
    }

my bean falls over after I run this method

public void addBooking(Long custno, Long tickno, Long quantity) { 
    Customer cust = (Customer) em.createNamedQuery("findCustomerByPrimaryKey").setParameter("eid", custno).getSingleResult();
    Booking b = new Booking();

        b.setBookeddate(new Timestamp(System.currentTimeMillis()));

        b.setCustomer(cust);

        b.setTicket((Ticket) em.createNamedQuery("findTicketByPrimaryKey").setParameter("eid", tickno).getSingleResult(), quantity);

        cust.addBooking(b);

        //persistBooking(b);
  }

And this is my error message.

javax.ejb.EJBException: BEA1-001D72BA69DC9E472B1E: Local Exception Stack: 
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: ORA-00904: "CUSTOMER_CUSTOMERNO": invalid identifier

Error Code: 904
Call: INSERT INTO BOOKING (bookingNo, ITEMNAME, BOOKINGDATE, BOOKINGVALUE, ITEMNO, QUANTITY, BOOKEDDATE, CUSTOMER_customerNo) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
    bind => [71, Metallica, 2011-01-05 22:07:17.788, 200.0, 420, 2, 2011-01-05 22:07:17.788, 1526]
Query: InsertObjectQuery(courseworkone.Booking@201a41)
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:324)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:801)
  • 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-19T00:30:50+00:00Added an answer on May 19, 2026 at 12:30 am

    Your customer mapping is using the default column name which is “CUSTOMER_CUSTOMERNO”, but you have created your table using “custNo”. You need to use the correct column name.

    i.e.

    @ManyToOne
    @JoinColumn(name="custNo")
    public Customer getCustomer() {
        return customer;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My understanding of Multiset is a set with frequency, but I can always use
My understanding is that Processing.js converts Processing code into javascript. But if one does
My understanding: Mercurial has three levels of config files: one shared by all users
My understanding is that the queue based approach to concurrency can be implemented without
My understanding is that it means that one can potentially write a program to
My understanding of the Git pack file format is something like: Where the table
After understanding (quote), I'm curious as to how one might cause the statement to
See: Understanding Pointers In many C flavoured languages, and some older languages like Fortran,
My understanding is that a .NET application is platform independent, so pure .NET code
My understanding is that when you kill a C++ application through Task Manager in

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.