I know it is a rookie question but how do I get the system to print what is in personList?

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;
        }
    }

possibly

while(personList.iterator().hasNext()){
        personList.iterator();
        }

Thanks
-Steve

Recommended Answers

All 2 Replies

for (int i=0;i<personList.size();i++) {
  String s = personList.get(i);
}

Hibernate: select trips0_.PERSONID as PERSONID1_, trips0_.TRIPID as TRIPID1_, trips0_.TRIPID as TRIPID1_0_, trips0_.PERSONID as PERSONID1_0_, trips0_.DEPDATE as DEPDATE1_0_, trips0_.DEPCITY as DEPCITY1_0_, trips0_.DESTCITY as DESTCITY1_0_, trips0_.TRIPTYPEID as TRIPTYPEID1_0_ from TRIP trips0_ where trips0_.PERSONID=?

thanks for that code.

I got this output(above).
Does this make sense to you. I am trying to take this program apart (HibernateTravelApp) to see how it works.

Right now I am trying to figure out how my session bean is is interacting with the JSF,the object classes and the mapping.hbm.xml anlong with the session bean.

I have deducted that the JSF end simply fills in the table with a row of data but one row is kinda understood how it gets the values from the db but somehow it is like incrementing through the database with the above query. maybe because of the xml that has the code that reads:

<id column="PERSONID" name="personId">
            <generator class="increment"/>
        </id>

also I have not confirmed how the above SELECT statement got formed. I am in the process of trying to understand how the session bean methods are gathering the items to fill the query but the query itself (SELECT etc structure) must be implicit in some class.
If you could shed some light on the specifics of hbm I would appreciate 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.