Creating A New Table

  1. To create a new table, open up at WST_Manager_Webapp/src/META-INF/newDatabaseMySQL.sql
  2. Read the precautions at the top of the file on how to format your SQL statements.
  3. Write a new SQL table in that format (note that the way that it creates foreign keys in this database should be copied and pasted -- there are many ways to create a foreign key that won't be automatically picked up in NetBeans JPA).
  4. Open up the database, perhaps in MYSQL Query Browser, and run the SQL (make sure it ran without errors).
  5. Start up NetBeans. Open the CIAB_Icefaces_Netbeans project.
  6.  Are you changing an existing table?
    1. If you added or removed fields or connections, you will need to delete the old ciab.jpa files before following the next step to re-add them.
  7. Or are you adding a new table?
    If your SQL includes new tables, follow this section.
    1. Go to the "Services" tab, find your database, and right-click "Connect" to it.
    2. Right click on the project and select "New" -> "Entity Classes From Database".
    3.  Click the "Data Source" radio button and then select the database you're using.
    4. Select the new tables and "Add >" them. Click "Next".
    5. Make sure the names are correct. Make sure the package is "ciab.jpa".
    6. Open up "CIAB_Icefaces_Netbeans/Configuration Files/persistence.xml". Switch to the "XML" view. Below "<class>ciab.jpa.Source</class>" add any new classes that you've created. (This isn't supposed to be necessary, but Hibernate doesn't always automatically find all of the hibernate classes).
    7. Back on the "Projects" tab right click on "CIAB_Icefaces_Netbeans" -> "New" -> "JPA Controller Classes from Entity Classes".
      Add the selected class and change the package to "ciab.jpa.controllers".
      (Sometimes, if your class doesn't show in this list, you may have to quit NetBeans and start it up again)
    8. Back in Eclispe, "Refresh" the real project.