[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] ManyToOne on non primary keys

This should work.  Please include the exception include stack trace that you
are getting.  It is most likely an issue with the annotations processing, as
EclipseLink does support ManyToOne's not by primary key.  If this is the
case, then please log a bug.

As a workaround you can use a DescriptorCustomizer to get the mapping
(OneToOneMapping) from the ClassDescriptor and reset the foreign key fields
(probably easiest to set one foreign key in annotations to avoid defaults,
then call addForeignKeyFieldName() to add the other).



machac wrote:
> 
> Hallo,
> 
> we have one problem:
> 
> we use OpenJPA implementation and this use case works and we want migrate
> to EclipseLink 
> but testing on entities
> 
> public class Zak {
>      @Id
>      private int id;
> 
>      @Column(name="zak_number")
>      private String number;
> 
>      @Column(name="zak_year")
>      private int year;
> 
>      @Column(name="zak_name")
>      private String name;
> 
>      @ManyToOne
>      @JoinColumns({
>          @JoinColumn(name="zak_ana", referencedColumnName="ana_number"),
>          @JoinColumn(name="zak_year", referencedColumnName="ana_year")
>      })
>      private Ana ana;
> 
>      ...
> }
> 
> 
> public class Ana {
>      @Id
>      private int id;
> 
>      @Column(name="ana_number")
>      private String number;
> 
>      @Column(name="ana_year")
>      private int year;
> 
>      @Column(name="ana_name")
>      private String name;
> 
>      ...
> }
> 
> failed because EclipseLink noted then Zak used 2 joined columns to mapp
> Ana but Ana has 
> only one primary key. Tables we can not changed because are from external
> SW
> 
> Supports EclipseLink mapping unidirectional ManyToOne to non pripary keys
> columns?
> 
> Thank's for any answer or help with such mapping.
> Zdenek Machac
> 


-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/ManyToOne-on-non-primary-keys-tp19435773p19494584.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.