Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Re: N-M-Table and Additional Fields (Joe Mc.)

Hi,
to me it appears most reasonable to split the ManyToMany relationship into two OneToMany relationships and to add a new entity class (e.g. "WorkContract"). Now, this new entity class would have the OneToMany references to "Job" and one to "Person" and an attribute "Salary".

Best regards,
Reinhard

eclipselink-users-request@xxxxxxxxxxx wrote:
Send eclipselink-users mailing list submissions to
	eclipselink-users@xxxxxxxxxxx

To subscribe or unsubscribe via the World Wide Web, visit
	https://dev.eclipse.org/mailman/listinfo/eclipselink-users
or, via email, send a message with subject or body 'help' to
	eclipselink-users-request@xxxxxxxxxxx

You can reach the person managing the list at
	eclipselink-users-owner@xxxxxxxxxxx

When replying, please edit your Subject line so it is more specific
than "Re: Contents of eclipselink-users digest..."


Today's Topics:

   1. Re: N-M-Table and Additional Fields (Joe Mc.)


----------------------------------------------------------------------

Message: 1
Date: Mon, 16 Mar 2009 02:24:35 -0700 (PDT)
From: "Joe Mc." <m_joe_c@xxxxxxxxxxx>
Subject: Re: [eclipselink-users] N-M-Table and Additional Fields
To: eclipselink-users@xxxxxxxxxxx
Message-ID: <22534303.post@xxxxxxxxxxxxxxx>
Content-Type: text/plain; charset=us-ascii


So, one solution could be to use explicit the n-m-Table as domain class and
use ManyToOne on both sides to this n-m-Table domain class.
The Person contains a list of Person_has_Job objects, instead of Job
objects. The same on the Job side.

I do not like this solution.
Any (better) solutions?



Joe Mc. wrote:
Hi everybody,

I have following scenario:
2 Tables with a n-m-relation. That means, I have a third table for the
n-m-Relation. In this third table I have additional fields.
artificial Example:
Person has a Job and the Job could be done from more tha one Person. But
the salary is not for every Person and Job the same.
Tables:
Person(id, name)
Job(id, title)
Person_has_Job(person_id, job_id, salary)

Ok. How is the JPA realisation? ;-)
I can work with ManyToMany and I can define with JoinTable the n-m-table.
But how is it possible to set the salary value in a (transient) property
of Job (Job#salary)

I think the example and the reason are clear. Howevery I do not know the
best solution with JPA.
Any Hints?

Thanks in advance!

M.Joe








--
Oracle <http://www.oracle.com>
Reinhard Girstenbrei | Senior Principal Technical Support Engineer
Phone: +498914302318 | Mobile: +491775941318
Oracle Oracle Customer Service

ORACLE Deutschland GmbH | Riesstr. 25 | 80992 München

ORACLE Deutschland GmbH, Hauptverwaltung: Riesstraße 25, D-80992 München
Geschäftsführer: Jürgen Kunz, Registergericht: Amtsgericht München, HRB 82775 Green Oracle <http://www.oracle.com/commitment> Oracle is committed to developing practices and products that help protect the environment



Back to the top