Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] ManyToMany with aditional fields

On Thu, Jul 9, 2009 at 4:25 PM, christopher
delahunt<christopher.delahunt@xxxxxxxxxx> wrote:
> Sorry, didn't realize the links where to your classes and not to a
> signature.
> It looks  like you put the relationships in your PKClass and just used basic
> types in your ItemOrder class, which is backwards.
> The specification does not allow primary key classes to contain
> relationships - they can only contain basic types.
> Because you are using an embeddable, you do not need to map anything other
> than the quantity in your ItemOrder, and just use itemOrder.id.orderId
> to get at the integer values.  If you want to have the relationships, you
> can add Order and Item ManyToOne mappings to the ItemOrder but be sure to
> mark the columns as insertable=false updatable=false so
> that you only have one writable mapping to the column.  If you are using the
> latest EclipseLink which implements the @MappedById, you can instead use it
> to point to the corresponding id mapping in the embeddable
> (avoiding having to define the join column name and mark it as
> insertable=false updatable=false).
> Best Regards,
> Chris
>
>
> John Arevalo wrote:
>>
>> Hi, thank you for your quick reply.
>>
>> ItemOrderPK is posted in 1st pastebin link. Full JoinColumn Annotation is:
>> @JoinColumn(name="item_id",referencedColumnName="item_id")
>> @ManyToOne
>> private Item item;
>>
>> --
>> John Arévalo
>> GNU/Linux User #443701
>> http://counter.li.org/
>> _______________________________________________
>> eclipselink-users mailing list
>> eclipselink-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>>
>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>

Thanks Christopher, it worked perfectly adding non-updatable JoinColumn.

MappedId won't be portable to another JPA implementation, doesn't it?

-- 
John Arévalo
GNU/Linux User #443701
http://counter.li.org/


Back to the top