Hello I have been studing the tutorial at
http://http://www.netbeans.org/kb/61/web/hibernate-vwp.html

I am starting to understand how data from a database gets to a webpage to a table via a selection box. But in the code I can not see where it actually build a SQL query
is there a method in one of these blocks of code that would build a query to extract all the data from the db based on a the item selected in a drop down list?

private void buildPersonOptions() {
        List<Person> personList = null;



        try {
            Session session = HibernateUtil.getSessionFactory().getCurrentSession();
            Transaction tx = session.beginTransaction();
            Query q = session.createQuery("from Person");
            personList = (List<Person>) q.list();

        } catch (Exception e) {
            e.printStackTrace();
        }

        personOptions = new Option[personList.size()];
        int i = 0;
        for (Person person : personList) {
            Option opt = new Option(person.getPersonId(), person.getName());
            personOptions[i++] = opt;
        }
        
    }

Yes, in the provide code there is a query.
"from Person" this is a HQL (Hibernate Query Language) query. Hibernate will generate SQL from HQL runtime. "from Peson" will genereate an SQL query like
"select <all hibernate mapped fields> from Person (Person class name will be changed with the table name mapped in Hibernate mapping file)".

Ok. Thanks. I was wondering about this code. I built a sessionbean class based on this(above) code. I have a db,mapping,3 entity classes too. I was able to get it in a web page but I can't figure out what part of the code is taking the xml piece of code

<id>generate class "increment"

which as far as I know is generating the something using the id that I set for the database.But somewhere in that code the id produces the instructor name but what code is responsible for poulating the dropdown list (with a name preferably). Now I have the binding set up but it isn't doing it
Thanks
-Steve

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.