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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

question about Enity mapping

Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A developer is designing a Java Persistence application that is mapped to a set of existing tables.
This set includes table EMPLOYEE, DEPARTMENT, and PROJECT. Tables EMPLOYEE and
DEPARTMENT do NOT define any foreign key constraints to table PROJECT. Table PROJECT
defines foreign key constraints with references to tables EMPLOYEE and DEPARTMENT and an
extra column called COST. The table EMPLOYEE is mapped to an entity Employee and the table
DEPARTMENT to an entity Department.
How can the table PROJECT be mapped so the persistence application can be portable?
A. Such sets of tables cannot be mapped and keep the application portable.
B. Map the table PROJECT as a secondary table for either the Employee or Department entity.
C. Map the table PROJECT to bidirectional many-to-many relationships between the Employee
and Department using a java.util.Map as the type of the field or property.
D. Map the table PROJECT to an entity Project with a field or property cost mapped to the
column COST and one-to-many relationships to this entity in the Employee and the

given answer is D,I figured out that Employee has a One-To-Many relationship with Project and Department has a One-To-Many relationship with Department(am i right?),and how to figure out are they unidirectional or bidirectional,and who is owning side?
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi vitesse wei,

A bidirectional ManyToMany ALWAYS need a join table.
(refer to the specs - Bidirectional ManyToMany Relationships).
In your mock, there is no join table, so answer C is false.

Hope it helps,

I don't like that guy. The tiny ad agrees with me.
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic