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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:57:35+00:00 2026-05-25T00:57:35+00:00

I’m just starting to work with persistence and databases in my use of webapps.

  • 0

I’m just starting to work with persistence and databases in my use of webapps. I have created several Entity classes and have a database connection set up in Eclipse, but I’m not sure how to generate the tables from those entities. This is all I’ve managed to come up with so far:

public class Main {

    @Resource
    static UserTransaction utx;

    @PersistenceUnit
    static EntityManagerFactory emf;

  public static void main(String[] args) throws Exception {
    EntityManager em = emf.createEntityManager();
    utx.begin();
    em.joinTransaction();

    User user = new User();
    user.setUsername("cvolkernick");

    em.persist(user);

    utx.commit();

    em.flush();

    em.close();
    emf.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-05-25T00:57:35+00:00Added an answer on May 25, 2026 at 12:57 am

    You can create Tables from Entity declarations, using the Dali JPA Tools. As long as your project is configured with a JPA facet, you will have access to these tools. Creating tables from entities is as simple as right-clicking on your project, and then browsing through the context menu, as shown in the below screenshot:

    Eclipse- JPA - Create Tables from Entities

    Note that it is preferable to create tables in this manner, or by hand-coding the DDL statements yourself. It is not recommended to have the JPA provider create the tables for you, as you would lose the ability to place the table definitions under version control. They’re also suboptimal and not meant to be used in production. Even for small projects, it is not worth the trouble, as the ability of the JPA provider (EclipseLink or Hibernate) to generate fine-tuned DDL statements is quite limited. In any case, if you wish to have the JPA provider do this work for you, details are as follows:

    If your JPA provider is EclipseLink:

    Your persistence.xml file ought to look like the following:

    <?xml version="1.0" encoding="UTF-8"?>
    <persistence ...>
        <persistence-unit ...>
            ...
            <properties>
                <!-- valid values include 'none, 'drop-and-create-tables' and 'create-tables' -->
                <property name="eclipselink.ddl-generation" value="create-tables"/>
                <!-- valid values include 'both', 'database' and 'sql-script' -->
                <property name="eclipselink.ddl-generation.output-mode" value="database"/>
                ...
            </properties>
        </persistence-unit>
    </persistence>
    

    You can configure these values from Eclipse, by opening the persistence.xml file with the Persistence XML editor:

    EclipseLink Persistence XML editor

    Details of the EclipseLink schema generation properties and values can be found in the EclipseLink wiki.

    If your JPA provider is Hibernate:

    Your persistence.xml file ought to look like the following:

    <?xml version="1.0" encoding="UTF-8"?>
    <persistence ...>
        <persistence-unit ...>
            ...
            <properties>
                <!-- valid values include 'validate', 'update', 'create' and 'create-drop' -->
                <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
                ...
            </properties>
        </persistence-unit>
    </persistence>
    

    Unlike the EclipseLink values, the ones for Hibernate cannot be configured from the Persistence XML editor of Eclipse. You can find other Hibernate properties in the Hibernate Core documentation.

    Also, note that the in the case of both EclipseLink and Hibernate, you might need to specify additional properties like the connection pool configuration and the database dialect, to aid the schema generators.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a reasonable size flat file database of text documents mostly saved in
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into

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.