Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code 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 ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Toplink One Class From Two Seperate Table

 
Greenhorn
Posts: 1
  • 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

 
Ranch Hand
Posts: 553
  • 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.
 
My previous laptop never exploded like that. Read this tiny ad while I sweep up the shards.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic