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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:12:38+00:00 2026-06-19T00:12:38+00:00

Here is some entity: @Entity public class Forest { @Id @GeneratedValue(strategy = GenerationType.AUTO) private

  • 0

Here is some entity:

@Entity
public class Forest {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id;


    public Forest() {
    }

    public long getId() {
        return id;
    }

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

I want to insert some element in table forest:

public class Main {
private static EntityManagerFactory emf = 
       Persistence.createEntityManagerFactory("server");

    public static void main(String[] args) {

        EntityManager em = emf.createEntityManager();
        EntityTransaction trx = em.getTransaction();
        Forest forest = new Forest();


        trx.begin();
        em.persist(forest);
        trx.commit();

    }
}

Thrown exception:

Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: Table 'server.forest' doesn't exist

Caused by: org.hibernate.exception.SQLGrammarException: Table 'server.forest' doesn't exist

My persistence.xml file with settings:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
   <persistence-unit name="server">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>

      <properties>
          <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
          <property name="javax.persistence.jdbc.url"               value="jdbc:mysql://localhost:3306/server"/>
          <property name="javax.persistence.jdbc.user" value="root" />
          <property name="javax.persistence.jdbc.password" value="root" />
          <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
          <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
      </properties>
   </persistence-unit>
</persistence>

When I removed @GeneratedValue(strategy = GenerationType.AUTO) and set id for forest:
forest.setID(1), there was no exception and table has been generated. So, auto-generating of id is not working and I don’t know why.

  • 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-19T00:12:39+00:00Added an answer on June 19, 2026 at 12:12 am

    According configuration there is org.hibernate.dialect.HSQLDialect used with MySQL database. Using MySQL dialect instead of one of HSQL likely helps. Likely InnoDB is used – if so, then MySQL5InnoDBDialect is way to go.

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

Sidebar

Related Questions

really strange situation I got here. I have 2 classes. @Entity public class CategoryData
I have a criteria query not really working. Here the model: @Entity public class
Here is example: @Entity(name=Cat) public class Cat { @ManyToOne @JoinColumn(name=FoodId,nullable=true) public Food getFood() {
Imagine the following two entities. Element is simple class containing some data: @Entity public
for simplicity, here is my simplified model: I got 2 entities: @entity public class
Why does the titlebar overlap the pixels of JPanel. Here some code: protected void
Here is some code: class Person def initialize(age) @age = age end def age
I have the following entity public class Employee { public virtual int Id {get;set;}
I have 2 classes @Entity @Table(name = user) public class User @Id @Column(name =
Here is my problem in C# : I have the following classes: 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.