openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Linskey" <plins...@gmail.com>
Subject Re: Join table with extra value
Date Thu, 06 Sep 2007 16:23:36 GMT
Hi,

What goes into the value column?

> Should I define the mapping as A (OneToMany) A_B (ManyToOne) B and
> create an object for A_B?  If so, how do I do that?

You certainly could take that approach. You'd just set up a pair of
one-to-many relations from A to A_B and B to A_B; you wouldn't need to
do anything special to make it work.

-Patrick

On 9/6/07, Christian Defoy <christian.defoy@gmail.com> wrote:
> Hello,
>
> I have two objects, A and B, that are involved in a many to many
> relationship.  That portion works ok if class A contains:
>
>     @ManyToMany( fetch=FetchType.EAGER, cascade=CascadeType.ALL )
>     @JoinTable( name="a_b", joinColumns=@JoinColumn( name="a_id",
> referencedColumnName="a_id" ),
>                 inverseJoinColumns=@JoinColumn( name="b_id",
> referencedColumnName="b_id" ))
>     private Set<B> mappedBs;
>
> My problem is that the relationship between A and B must contain an
> additional value.  The join table between A and B looks like this:
>
> create table A_B
> (
>     a_id  integer not null,
>     b_id  integer not null,
>     value integer
> );
>
> Should I define the mapping as A (OneToMany) A_B (ManyToOne) B and
> create an object for A_B?  If so, how do I do that?
>
> Thanks in advance!
>
> Christian
>


-- 
Patrick Linskey
202 669 5907

Mime
View raw message