Hello.
I am presently tearing a HibernateTravelApp tutorial (http://www.netbeans.org/kb/61/web/hibernate-vwp.html) apart to see how it works and I was looking at the traveldb that ships with netbeans and I am having trouble understanding how the tables interact because the name table only has one row with names and I don't see any foreign key to relate it to the Id table or any table for that matter. Could someone clear this up? If I understood this I have to try to understand the xml in the tutorial which will be my next question concerning mapping the data and filling a list or(Set property in xml).with the data from the particular objects.
Thank you
-Steve

Well disregard the db question because I just ran a query and it makes perfect sense now. the last time I ran a SELECT * FROM travel.person it only showed one column now it shows all the columns so I am exploring the set property in the xml along with the other properties.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
  <class dynamic-insert="false" dynamic-update="false"
      mutable="true" name="travel.Person" optimistic-lock="version"
      polymorphism="implicit" select-before-update="false" table="PERSON">
        <id column="PERSONID" name="personId">
            <generator class="increment"/>
        </id>
        <property column="NAME" name="name"/>
        <property column="JOBTITLE" name="jobTitle"/>
        <property column="FREQUENTFLYER" name="frequentFlyer"/>
        <set cascade="all-delete-orphan" inverse="true" lazy="true" name="trips" table="TRIP">
            <key column="PERSONID"/>
            <one-to-many class="travel.Trip"/>
        </set>
    </class>
</hibernate-mapping>

the <id> has

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

what is this doing? because the db has an id column that seems to AUTO_INCREMENT so what is this code for?
-thanks
-Steve

I know its a rookie question but how do I 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

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.