I got the usage finally 
@ElementJoinColumns({...@elementjoincolumn(name="QUEUE_ID", 
referencedColumnName="QUEUE_ID"),
                @ElementJoinColumn(name="SITE_NUMBER", 
referencedColumnName="SITE_NUMBER")})

But then I have another question, I have a object structure like this,
@Entity 
@Table(name = "Queue") 
public class Queue implements Serializable { 
    . 
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column (name = "id",nullable = false)
     private Integer id;
    .
    @Column (name = "SITE_NUMBER")
     private Integer siteNumber = 0;
        
    @Column (name = "QUEUE_ID")
     private Integer queueId = 0;

    @OneToMany(fetch=FetchType.EAGER) 
        // joined with queue items by QUEUE_ID and SITE_NUMBER
     private Collection<QueueItems> queueItems ; 

} 
------------------------------------------------------ 

@Entity 
@Table(name = "Queue_Items") 
public class QueueItems implements Serializable { 
     @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column (name = "RECORD_NUMBER",nullable = false)
    private Integer recordNumber;     

    @Column (name = "QUEUE_ID") 
     private Integer queueId; 

   @Column (name = "SITE_NUMBER")
    private Integer siteNo;
} 


Now when I am using @ElementJoinColumns for queue items collection in Queue 
then it is giving me 
<openjpa-1.2.1-SNAPSHOT-r422266:686069 nonfatal general error> 
org.apache.openjpa.persistence.PersistenceException: null

>From data perspective it is a One to Many relationship but the schema does not 
>have a join on primary key. I can't modify schema, since I am rewriting an 
>existing application.

Can you please advice on which annotation I should use for this Join?
Please suggest.

Thanks and regards,
Joshi



Thank you Pinaki. 
It says "enclose an array of ElementJoinColumns in the 
org.apache.openjpa.persistence.jdbc.ElementJoinColumns annotation"

should this be array of ElementJoinColumns or ElementJoinColumn? Also can you 
please provide me the syntax of how to use @ElementJoinColumns ?

Thanks again,
Joshi

See [1]

[1] 
http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_mapping_jpa_coll_joincols


Can I specify more than one columns along with @ElementJoinColumn? If yes then 
how do I do that? I have one sided one to many relationship with composite 
foreign keys.






-- 
View this message in context: 
http://n2.nabble.com/%40ElementJoinColumn-more-than-one-columns-tp2635985p2639737.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to