Hello I have been studing the tutorial at

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) {

        personOptions = new Option[personList.size()];
        int i = 0;
        for (Person person : personList) {
            Option opt = new Option(person.getPersonId(), person.getName());
            personOptions[i++] = opt;
8 Years
Discussion Span
Last Post by ceyesuma

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.