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

8 Years
Discussion Span
Last Post by ceyesuma

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">
  <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"/>
        <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"/>

the <id> has

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

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


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) {
        personOptions = new Option[personList.size()];
        int i = 0;
        for (Person person : personList) {
            Option opt = new Option(person.getPersonId(), person.getName());
            personOptions[i++] = opt;




This question has already been answered. 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.