in this xml mapping file :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "">
  <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"/>

what does this code do?

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

<id/> tag will define colum "PERSONID" as the primary key for the object Person. It is not required in hibenate that PERSONID colum is a primary key to be declared as a primary key for the object.
Generator = increment means hibernate will treat this column like an AUTO GENERATED or SEQUENCE. When you save a Person object you dont have to pass a value for PERSONID. Hibernate will generate i for you.

Be a part of the DaniWeb community

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