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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:30:44+00:00 2026-06-01T19:30:44+00:00

I have a database with the following table structures… The Customer table has two

  • 0

I have a database with the following table structures…

The Customer table has two columns : id, name.

The Order table has two columns: id, customer_id

There is a one-to-one relation between these two tables

When I run my code, which is given below, I get the following exception:

Hibernate: insert into customer (name) values (?)
Hibernate: insert into order (customer_id) values (?)
05:02:46,374  WARN [main] JDBCExceptionReporter:233 - SQL Error: 0, SQLState: 42601
05:02:46,379 ERROR [main] JDBCExceptionReporter:234 - ERROR: syntax error at or near "order"

Here is my code. Could someone help to explain the cause of the problem…

@Entity
@Table(name = "customer")
public class Customer implements Serializable {


    public Customer() {
    }

    private long id;
    private String name;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", insertable = false, updatable = false, nullable = false)
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    @Column(name = "name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}


@Entity
@Table(name = "order")

public class Order implements Serializable {
    public Order() {
    }

    public Order(Customer customer) {
        this.customer = customer;
    }

    private long id;
    private Customer customer;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", insertable = false, updatable = false, nullable = false)
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    @OneToOne(cascade = { CascadeType.ALL })
    @JoinColumn(name = "customer_id")
    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
        // setCustomerId(customer.getId());
    }
}

public static void main(String[] args) {

    Customer cm = new Customer();
    cm.setName("John");
    
    Order ord = new Order(cm);

    SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
    Session session = sessionFactory.openSession();

    Transaction transaction = null;

    try {
        transaction = session.beginTransaction();
        session.save(ord);
        transaction.commit();
}
    catch (HibernateException e) {
        transaction.rollback();
        e.printStackTrace();
    }
    finally {
        session.close();
    }

}
  • 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-01T19:30:46+00:00Added an answer on June 1, 2026 at 7:30 pm

    order is a SQL keyword. If you can’t change the database name, try using:

    @Table( name = "\"order\"" )
    

    But if you’re still in development, change table and column names to avoid using SQL keywords.

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

Sidebar

Related Questions

I have a SQL database that has the following table: Table: PhoneRecords -------------- ID(identity
I have the following database structure: Event table Id - Guid (PK) Name -
I have the following database structure: Sites table id | name | other_fields Backups
I have the following database structure: Table 1 Table 2 Table 3 tid_1 ----(many-to-one)----
I have no control over database schema and have the following (simplified) table structure:
I have two database tables with the following structure: actions: action_id int(11) primary key
I have a database with the following table: PATIENT (PATIENT_ID*, MEDICAL_EXAMINATIONS) where the field
Let's say I have the following database table: record_id | record_date | record_value -----------+-------------+--------------
Suppose I have an Oracle 11.2 database containing the following table: TABLE: SURVEY PARAMETER
I have the following table in a SQLite3 database: CREATE TABLE overlap_results ( neighbors_of_annotation

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.