• 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

question about Enity mapping  RSS feed

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,

We cannot change unless we survive, but we will not survive unless we change. Evolving tiny ad:
ScroogeXHTML - small and flexible RTF to HTML converter library
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!