Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Parent-Child Confusion ....

Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

Please refer the mapping and bean classes below.

<class name="com.test.beans.Employee" table="Employee">

<id name="empId" column="id">
<generator class="foreign">
<param name="property">department</param>

<property name="name">
<column name="name" />

<one-to-one name="department" cascade="all"
class="com.test.beans.Department" constrained="true"></one-to-one>


<class name="com.test.beans.Department" table="Department">
<id name="Id" type="long" column="id" unsaved-value="0">
<generator class="increment" />

<property name="deptName" unique="true">
<column name="deptName" />



public class Department {
private long Id;
private String deptName;
.............................Gettr Setters.......


public class Employee {
private String name;
private long empId;
Department department;
.............................Gettr Setters.......


My Question is if Employee table is parent of Department as Employees compposes Department ? Or reverse is true i.e Department table is parent of Employee.

When I try assosiated Department Object also gets saved in Department table whereas this is not the case when I try as it only saves Department object.

Thanks & Regards
Maneesh Saxena

I suggest huckleberry pie. But the only thing on the gluten free menu is this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic