[nbusers] CRUD Tutorial with custom DB issue

  • From: "DanDanSC" < >
  • To:
  • Subject: [nbusers] CRUD Tutorial with custom DB issue
  • Date: Wed, 09 Jan 2013 00:36:49 -0500

Hello,

I am currently working through the NetBeans CRUD tutorial
http://platform.netbeans.org/tutorials/nbm-crud.html#creating-entity

However, I am not using the sample database. I am learning the code and 
adapting it to my own database. I made it to the part right after you do the 
imports to the CustomerViewer Module. Mine is called EmployeeViewer. The 
issue arises at this statement:

jTextArea1.append(c.getName() + " (" + c.getCity() + ")" + "\n");

I have treid to simply change it to get a piece of data that exists in my 
database. Such as FIRST_NAME, but this does not work

jTextArea1.append(c.getFIRST_NAME() + " (" + c.getCity() + ")" + "\n");

So how can I fix this to get the table columns I need? The error says:
cannot find symbol
symbol: method getFIRST_NAME()
location: variable c of type Employees


Here is my code for the whole page:

package org.shop.viewer;

import eedata.Employees;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import javax.persistence.Query;
import org.netbeans.api.settings.ConvertAsProperties;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.windows.TopComponent;
import org.openide.util.NbBundle.Messages;

/**
 * Top component which displays something.
 */
@ConvertAsProperties(
    dtd = "-//org.shop.viewer//EmployeeViewer//EN",
autostore = false)
@TopComponent.Description(
    preferredID = "EmployeeViewerTopComponent",
//iconBase="SET/PATH/TO/ICON/HERE", 
persistenceType = TopComponent.PERSISTENCE_ALWAYS)
@TopComponent.Registration(mode = "explorer", openAtStartup = true)
@ActionID(category = "Window", id = 
"org.shop.viewer.EmployeeViewerTopComponent")
@ActionReference(path = "Menu/Window" /*, position = 333 */)
@TopComponent.OpenActionRegistration(
    displayName = "#CTL_EmployeeViewerAction",
preferredID = "EmployeeViewerTopComponent")
@Messages({
    "CTL_EmployeeViewerAction=EmployeeViewer",
    "CTL_EmployeeViewerTopComponent=EmployeeViewer Window",
    "HINT_EmployeeViewerTopComponent=This is a EmployeeViewer window"
})
public final class EmployeeViewerTopComponent extends TopComponent {

    public EmployeeViewerTopComponent() {
        initComponents();
        setName(Bundle.CTL_EmployeeViewerTopComponent());
        setToolTipText(Bundle.HINT_EmployeeViewerTopComponent());
EntityManager entityManager = 
Persistence.createEntityManagerFactory("EED_LibraryPU").createEntityManager();
Query query = entityManager.createNamedQuery("Employees.findAll");
List<Employees> resultList = query.getResultList();
for (Employees c : resultList) {
  jTextArea1.append(c.getFIRST_NAME() + " (" + c.getCity() + ")" + "\n");
}
    }

    /**
     * This method is called from within the constructor to initialize the 
form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jScrollPane1.setViewportView(jTextArea1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(108, 108, 108)
                .addComponent(jScrollPane1, 
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(126, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(92, 92, 92)
                .addComponent(jScrollPane1, 
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(112, Short.MAX_VALUE))
        );
    }// </editor-fold>

    // Variables declaration - do not modify
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    // End of variables declaration
    @Override
    public void componentOpened() {
        // TODO add custom code on component opening
    }

    @Override
    public void componentClosed() {
        // TODO add custom code on component closing
    }

    void writeProperties(java.util.Properties p) {
        // better to version settings since initial version as advocated at
        // http://wiki.apidesign.org/wiki/PropertyFiles
        p.setProperty("version", "1.0");
        // TODO store your settings
    }

    void readProperties(java.util.Properties p) {
        String version = p.getProperty("version");
        // TODO read your settings according to their version
    }
}



And also the columns in the Employees table that I am querying here are:
EMPLOYEE_NUMBER
FIRST_NAME
LAST_NAME
EMAIL_ADDRESS
PHONE_NUMBER
CELL_NUMBER
STREET_ADDRESS
CITY
STATE
ZIP_CODE

so I could also use tips on adding columns to query and display in the app, 
as well as different tables. (How to do this in the code)

Thank you very much for the help!






[nbusers] CRUD Tutorial with custom DB issue

DanDanSC 01/09/2013

[nbusers] Re: CRUD Tutorial with custom DB issue

Geertjan Wielenga 01/09/2013

[nbusers] Re: CRUD Tutorial with custom DB issue

Edson Richter 01/09/2013

[nbusers] CRUD Tutorial with custom DB issue

DanDanSC 01/09/2013

Project Features

About this Project

www was started in November 2009, is owned by jpirek, and has 21 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close