hibernate mappinigs

db queries
------------

  CREATE TABLE TEST1
   (    "ID" NUMBER NOT NULL ENABLE,
    "DESC" VARCHAR2(20 BYTE),
     CONSTRAINT "TEST1_PK" PRIMARY KEY ("ID")

   ) ;


  CREATE TABLE "SYSTEM"."TEST2"
   (    "T2ID" NUMBER NOT NULL ENABLE,
    "T1FKID" NUMBER NOT NULL ENABLE,
    "T2DESC" VARCHAR2(20 BYTE),
     CONSTRAINT "TEST2_PK" PRIMARY KEY ("T2ID")
      CONSTRAINT "TEST2_TEST1_FK1" FOREIGN KEY ("T2ID")
     REFERENCES TEST1 ("ID") ON DELETE CASCADE ENABLE
   );


  CREATE TABLE "SYSTEM"."TEST3"
   (    "T3ID" NUMBER NOT NULL ENABLE,
    "T11FK1D" NUMBER NOT NULL ENABLE,
    "T2FK1D" NUMBER NOT NULL ENABLE,
    "T3DESC" VARCHAR2(20 BYTE),
     CONSTRAINT "TEST3_PK" PRIMARY KEY ("T3ID", "T11FK1D", "T2FK1D"),
      CONSTRAINT "TEST3_TEST1_FK1" FOREIGN KEY ("T11FK1D")
      REFERENCES TEST1 ("ID") ENABLE,
     CONSTRAINT "TEST3_TEST2_FK1" FOREIGN KEY ("T2FK1D")
      REFERENCES TEST2 ("T2ID") ENABLE
   ) ;






test1.hbm.xml
----------------
<?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">
<!--
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="comjava.Test1" table="TEST1" schema="SYSTEM">
        <id name="id" type="java.math.BigDecimal">
            <column name="ID" precision="22" scale="0" />
            <generator class="assigned" />
        </id>
        <property name="desc" type="java.lang.String">
            <column name="DESC" length="20" />
        </property>
        <set name="test3s" inverse="true">
            <key>
                <column name="T11FK1D" precision="22" scale="0" not-null="true" />
            </key>
            <one-to-many class="comjava.Test3" />
        </set>
        <one-to-one name="test2" class="comjava.Test2"></one-to-one>
    </class>
</hibernate-mapping>


test2.hbm.xml
--------------

<?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">
<!--
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="comjava.Test2" table="TEST2" schema="SYSTEM">
        <id name="t2id" type="java.math.BigDecimal">
            <column name="T2ID" precision="22" scale="0" />
            <generator class="assigned" />
        </id>
      
        <one-to-one name="test1" class="comjava.Test1" constrained="true"></one-to-one>
      
        <property name="t1fkid" type="java.math.BigDecimal">
            <column name="T1FKID" precision="22" scale="0" not-null="true" />
        </property>
      
        <property name="t2desc" type="java.lang.String">
            <column name="T2DESC" length="20" />
        </property>
      
        <set name="test3s" inverse="true">
            <key>
                <column name="T2FK1D" precision="22" scale="0" not-null="true" />
            </key>
            <one-to-many class="comjava.Test3" />
        </set>
      
      
      
    </class>
</hibernate-mapping>


test3.hbm.xml
-------------

<?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">
<!--
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="comjava.Test3" table="TEST3" schema="SYSTEM">
        <composite-id name="id" class="comjava.Test3Id">
            <key-property name="t3id" type="java.math.BigDecimal">
                <column name="T3ID" precision="22" scale="0" />
            </key-property>
            <key-property name="t11fk1d" type="java.math.BigDecimal">
                <column name="T11FK1D" precision="22" scale="0" />
            </key-property>
            <key-property name="t2fk1d" type="java.math.BigDecimal">
                <column name="T2FK1D" precision="22" scale="0" />
            </key-property>
        </composite-id>
      
      
        <many-to-one name="test1" class="comjava.Test1" update="false" insert="false" fetch="select">
            <column name="T11FK1D" precision="22" scale="0" not-null="true" />
        </many-to-one>
      
        <many-to-one name="test2" class="comjava.Test2" update="false" insert="false" fetch="select">
            <column name="T2FK1D" precision="22" scale="0" not-null="true" />
        </many-to-one>
        <property name="t3desc" type="java.lang.String">
            <column name="T3DESC" length="20" />
        </property>
    </class>
</hibernate-mapping>


java classes
--------------

test1.java
-----------
package comjava;

import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Set;


/**
 * Test1 entity. @author MyEclipse Persistence Tools
 */

public class Test1  implements java.io.Serializable {


    // Fields  

     private BigDecimal id;
     private String desc;
     private Set test3s = new HashSet(0);
     private Test2 test2;


    // Constructors

    /** default constructor */
    public Test1() {
    }

    /** minimal constructor */
    public Test1(BigDecimal id) {
        this.id = id;
    }
  
    /** full constructor */
    public Test1(BigDecimal id, String desc, Set test3s, Test2 test2) {
        this.id = id;
        this.desc = desc;
        this.test3s = test3s;
        this.test2 = test2;
    }

 
    // Property accessors

    public BigDecimal getId() {
        return this.id;
    }
  
    public void setId(BigDecimal id) {
        this.id = id;
    }

    public String getDesc() {
        return this.desc;
    }
  
    public void setDesc(String desc) {
        this.desc = desc;
    }

    public Set getTest3s() {
        return this.test3s;
    }
  
    public void setTest3s(Set test3s) {
        this.test3s = test3s;
    }

    public Test2 getTest2() {
        return this.test2;
    }
  
    public void setTest2(Test2 test2) {
        this.test2 = test2;
    }

}


test2.java
-----------
package comjava;

import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Set;


/**
 * Test2 entity. @author MyEclipse Persistence Tools
 */

public class Test2  implements java.io.Serializable {


    // Fields  

     private BigDecimal t2id;
     private Test1 test1;
     private BigDecimal t1fkid;
     private String t2desc;
     private Set test3s = new HashSet(0);


    // Constructors

    /** default constructor */
    public Test2() {
    }

    /** minimal constructor */
    public Test2(BigDecimal t2id, Test1 test1, BigDecimal t1fkid) {
        this.t2id = t2id;
        this.test1 = test1;
        this.t1fkid = t1fkid;
    }
  
    /** full constructor */
    public Test2(BigDecimal t2id, Test1 test1, BigDecimal t1fkid, String t2desc, Set test3s) {
        this.t2id = t2id;
        this.test1 = test1;
        this.t1fkid = t1fkid;
        this.t2desc = t2desc;
        this.test3s = test3s;
    }

 
    // Property accessors

    public BigDecimal getT2id() {
        return this.t2id;
    }
  
    public void setT2id(BigDecimal t2id) {
        this.t2id = t2id;
    }

    public Test1 getTest1() {
        return this.test1;
    }
  
    public void setTest1(Test1 test1) {
        this.test1 = test1;
    }

    public BigDecimal getT1fkid() {
        return this.t1fkid;
    }
  
    public void setT1fkid(BigDecimal t1fkid) {
        this.t1fkid = t1fkid;
    }

    public String getT2desc() {
        return this.t2desc;
    }
  
    public void setT2desc(String t2desc) {
        this.t2desc = t2desc;
    }

    public Set getTest3s() {
        return this.test3s;
    }
  
    public void setTest3s(Set test3s) {
        this.test3s = test3s;
    }

}


test3.java
----------

package comjava;



/**
 * Test3 entity. @author MyEclipse Persistence Tools
 */

public class Test3  implements java.io.Serializable {


    // Fields  

     private Test3Id id;
     private Test1 test1;
     private Test2 test2;
     private String t3desc;


    // Constructors

    /** default constructor */
    public Test3() {
    }

    /** minimal constructor */
    public Test3(Test3Id id, Test1 test1, Test2 test2) {
        this.id = id;
        this.test1 = test1;
        this.test2 = test2;
    }
  
    /** full constructor */
    public Test3(Test3Id id, Test1 test1, Test2 test2, String t3desc) {
        this.id = id;
        this.test1 = test1;
        this.test2 = test2;
        this.t3desc = t3desc;
    }

 
    // Property accessors

    public Test3Id getId() {
        return this.id;
    }
  
    public void setId(Test3Id id) {
        this.id = id;
    }

    public Test1 getTest1() {
        return this.test1;
    }
  
    public void setTest1(Test1 test1) {
        this.test1 = test1;
    }

    public Test2 getTest2() {
        return this.test2;
    }
  
    public void setTest2(Test2 test2) {
        this.test2 = test2;
    }

    public String getT3desc() {
        return this.t3desc;
    }
  
    public void setT3desc(String t3desc) {
        this.t3desc = t3desc;
    }

}

test3Id.java
--------------
package comjava;

import java.math.BigDecimal;


/**
 * Test3Id entity. @author MyEclipse Persistence Tools
 */

public class Test3Id  implements java.io.Serializable {


    // Fields  

     private BigDecimal t3id;
     private BigDecimal t11fk1d;
     private BigDecimal t2fk1d;


    // Constructors

    /** default constructor */
    public Test3Id() {
    }

  
    /** full constructor */
    public Test3Id(BigDecimal t3id, BigDecimal t11fk1d, BigDecimal t2fk1d) {
        this.t3id = t3id;
        this.t11fk1d = t11fk1d;
        this.t2fk1d = t2fk1d;
    }

 
    // Property accessors

    public BigDecimal getT3id() {
        return this.t3id;
    }
  
    public void setT3id(BigDecimal t3id) {
        this.t3id = t3id;
    }

    public BigDecimal getT11fk1d() {
        return this.t11fk1d;
    }
  
    public void setT11fk1d(BigDecimal t11fk1d) {
        this.t11fk1d = t11fk1d;
    }

    public BigDecimal getT2fk1d() {
        return this.t2fk1d;
    }
  
    public void setT2fk1d(BigDecimal t2fk1d) {
        this.t2fk1d = t2fk1d;
    }
 }


if u want to integrate spring with the ibernate project

the spring configuration will look like this

springConfig.xml
----------------

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">


    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="configLocation" value="file:src/hibernate.cfg.xml">
        </property>
    </bean>
</beans>