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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:10:50+00:00 2026-05-11T05:10:50+00:00

I have the following JPA entity classes (example case). A House belongs on a

  • 0

I have the following JPA entity classes (example case). A House belongs on a single Street. A Street has many Houses.

@Entity public class House {     @Id     @GeneratedValue(strategy=GenerationType.IDENTITY)     public Integer id;      public String name          @ManyToOne     public Street street; }  @Entity public class Street {     @Id     @GeneratedValue(strategy=GenerationType.IDENTITY)     public Integer id;      @OneToMany(mappedBy='street')     public Set<House> houses; } 

I have the generation type set to identity, which is supposed to auto assign a new ID.

When creating a new House with a new Street, I have to first create and persist Street, followed by House. This is because I do not have CascadeType set to PERSIST, so it has to be done manually [1]. However, while inserting a newly created Street:

Street street = new Street(); entityManager.persist(street); 

Hibernate/JPA generates the following SQL query:

insert into Street default values 

which MySQL doesn’t like.

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'default values' at line 1  

Any ideas why? I’m using Java 6, MySQL 5.0.67 with Hibernate’s implementation of JPA (version 3.2.1.ga).

[1] EJB 3 in Action pages 318-319

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T05:10:51+00:00Added an answer on May 11, 2026 at 5:10 am

    Standard SQL specifies this optional syntax for INSERT:

    INSERT INTO <Table Name> DEFAULT VALUES 

    This is legal SQL syntax, supported, for example, by Microsoft SQL Server, PostgreSQL, and SQLite, but not by Oracle, IBM DB2, or MySQL.

    MySQL supports other syntax that achieve the same result:

    INSERT INTO <Table Name> () VALUES ()  INSERT INTO <Table Name> (col1, col2, col3) VALUES (DEFAULT, DEFAULT, DEFAULT) 

    In Hibernate, you should configure the SQL dialect properly, and it’s up to Hibernate to generate valid SQL for the target RDBMS brand.

    import org.hibernate.cfg.Configuration;  Configuration cfg = new Configuration(); cfg.setProperty('hibernate.dialect', 'org.hibernate.dialect.MySQLInnoDBDialect'); 

    You can also specify properties by placing a file named hibernate.properties in a root directory of the classpath.

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

Sidebar

Ask A Question

Stats

  • Questions 123k
  • Answers 123k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I've used the following code without problem to draw text… May 12, 2026 at 1:06 am
  • Editorial Team
    Editorial Team added an answer Qt is moving in this direction, with CSS-like styling and… May 12, 2026 at 1:06 am
  • Editorial Team
    Editorial Team added an answer Unclear if you want to exclude Nurses that work with… May 12, 2026 at 1:06 am

Related Questions

I have the following java class: package domain; //imports @Entity public class User {
I have a pretty simple JPA @ManyToMany relationship set up in my application. A
When I make relationsships with JPA using hibernate, some terrible long and ackward column
I have a simple Class Hierarchy that I am trying to get to work

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.