This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Toplink One Class From Two Seperate Table

 
Jeremy Ragsdale
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a simple table structure of Employees & Employee Extra Data - I Don't know why they split this out, anyway...

Here's My Environment
JDeveloper 10.1.3.4.0
SqlServer 2005
SQL Driver jtds1.2.2.jar
Windows XP

I have used Create Java Objects from Tables to Create My POJO's for Each Table but what I really want is one class that represents some data from both tables.
I tried Using a view but The Datasource is SQL Server and for some reason Toplink is not liking the view?

What I want is a Class that Has all the employee data plus a few of the fields from the Employee Extra Data Table.

How I am getting around this is to add the fileds manually to the Employee class then

Employee = EmployeeByID(int id)
EmployeeExtraData = FindEmployeeExtraDataByID(int id)
SetEmployeeMobile(EmployeeExtraData().getMobile())

This works of course and for one employee is not that big of a deal but what happens when I do a wildcard serach that returns 1000+ employees.

I will have to loop through each record to update the Mobile field???

There has to be a better way to do this?

Can anyone please help.

Thanks in advance

 
James Sutherland
Ranch Hand
Posts: 553
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should use a multiple table descriptor for the Employee class. i.e. Just map the class to both tables, then TopLink will join the data.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic