• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

question about Enity mapping

 
vitesse wei
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question:
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
Department.

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?
 
Benoît de Chateauvieux
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi vitesse wei,

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

Hope it helps,

Beno�t
 
You showed up just in time for the waffles! And this tiny ad:
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
reply
    Bookmark Topic Watch Topic
  • New Topic