openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JoshiJPA <>
Subject Re: @ElementJoinColumn more than one columns
Date Wed, 15 Apr 2009 16:12:34 GMT

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,
@Table(name = "Queue") 
public class Queue implements Serializable { 
    @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;

        // joined with queue items by QUEUE_ID and SITE_NUMBER
     private Collection<QueueItems> queueItems ; 


@Table(name = "Queue_Items") 
public class QueueItems implements Serializable { 
    @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
<openjpa-1.2.1-SNAPSHOT-r422266:686069 nonfatal general error> org.apache.openjpa.persistence.PersistenceException:

>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,

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

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

Thanks again,

See [1]


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:
Sent from the OpenJPA Users mailing list archive at

View raw message