Bug 263 : Add support for joining to Non - PK columns
Priority 
High
Reported Version 
 
Logged By 
Rob
Status 
Fixed
Fixed Version 
2.6.0
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
31/03/2010
Updated 
31/03/2010
Type 
Bug
 
Attachments 
No attachments
@ManyToOne
    @JoinColumn(name="company_name", referencedColumnName="co_name")
    private Company company;

Normally the "referencedColumnName" is expected to be a primary key column.

This is a change to allow a non-primary key column to be used instead.

NOTE: This is NOT A RECOMMENDED APPROACH - but if you are dealing with a schema that has such a design you may need this.

 
Rob 31 Mar 04:42
So then...
List<Something> list = Ebean.find(Something.class)
            .fetch("company")
            .findList();

Results in:

select s.id c0, s.some c1
        , sc.comp_id c2, sc.co_name c3 
from something s
left outer join company sc on sc.co_name = s.company_name

Rob 31 Mar 04:44
Initial support in HEAD.

Code changed in head to allow this.

Will deploy in snapshot and get Rien to confirm that it works as expected.

Rob 31 Mar 04:48
Uploaded snapshot ...

woResponse

Upload a file