-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Generating OM for the tables having relationship.
PostPosted: Mon Apr 03, 2006 9:54 am 
Newbie

Joined: Sat Mar 25, 2006 5:12 am
Posts: 6
Location: Pune
Hi All,
I am having two tables as below
1> Employee( emp_id, dept_id, emp_name, salary)
emp_id as Pk
dept_id as Fk

2> Department(dept_id, dept_name)
dept_id as Pk

And the corresponding java classes are
1> Employee
int empId;
int deptId;
String empName;
int salary;

2> Department
int deptId;
String deptName;
Set employees;


Now as you see a department can have many employees. And if i use the hibernate to generate OM(object models) for "Employee" and "Department" i can just put "one-to-many" relationship in employee.hbm.xml file for the class Department, which i know can be done and is fine, but for some weired reasons i have to use "Stored Procedures" here i can use "Sql-query" and just call that procedure inside (Only if i have to represent one class at a time say Department) for this i can provide mappings such that each column i am returning will get mapped to one property of the Department class using "<return-property>" of a "Sql-query". but when relationship of the Employee to the Department comes i have no idea what to do (Please help me!) .
I wanted the OM's for each employee should get generate for the corresponding department so that the generated OM's for Employees will have reference for the OM of Department (i do not want to write any extra code here) just as what happens when we specify "one-to-many" relationship tag in hbm.xml file and make a call to Department and have access to Employee objects inside it.


Thanx in advance
Yuwaraj



Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.