my dog learned polymorphism
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes question about Enity mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "question about Enity mapping" Watch "question about Enity mapping" New topic

question about Enity mapping

vitesse wei
Ranch Hand

Joined: Sep 07, 2007
Posts: 100
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?

SCJP 5.0<br />SCWCD1.4<br />SCBCD5
Benoît de Chateauvieux
Ranch Hand

Joined: Aug 10, 2007
Posts: 183
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,


SCJP5 | SCBCD5 | SCEA5 Part 1
I agree. Here's the link:
subject: question about Enity mapping
It's not a secret anymore!