OUTER JOIN to Secondary Table

View: New views
4 Messages — Rating Filter:   Alert me  

OUTER JOIN to Secondary Table

by ashakirin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is it any way in EclipseLink to make OUTER JOIN to Secondary Table?

Use case: There is a main employee table that may or may not have some extra data populated in a related secondary table. If there is data in the secondary table (@SecondaryTable), then I would like my Employee entity to have those fields filled in. If there isn't data for a given employee in the secondary table, then I would like my Employee entity to have nulls in those fields. Right now, if there's no row in the secondary table for a given employee, I get nothing.

Unfortunately I cannot find acceptable solution in Internet.
Is INNER JOIN for Secondary Table fixed by design?

Regards,
Andrei.

Parent Message unknown OUTER JOIN to Secondary Table

by Andrei Shakirin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hello,
 
Is it any way in EclipseLink to make OUTER JOIN to Secondary Table?

Use case: There is a main employee table that may or may not have some extra data populated in a related secondary table. If there is data in the secondary table (@SecondaryTable), then I would like my Employee entity to have those fields filled in. If there isn't data for a given employee in the secondary table, then I would like my Employee entity to have nulls in those fields. Right now, if there's no row in the secondary table for a given employee, I get nothing.
I cannot use OneToOne relation for this case, because mapping is defined directly for one business domain object.

Here's example code:
 
@Entity @Table("EMPLOYEE") @SecondaryTable("EMPLOYEE_EXTRA", pkJoinColumns=@PrimaryKeyJoinColumn(name="EMPLOYEE_KEY"))
 
public class Employee implements java.io.Serializable {
 
private static final long serialVersionUID = -3789770304634576481L;
 
@Column(table="EMPLOYEE_EXTRA", name="EMPLOYEE_EXTRA_DATA",nullable=true) private String employeeExtraData;
 
@Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="EMPLOYEE_KEY") private Long employeeKey;
 
...etc
 
}
 
Unfortunately I cannot find acceptable solution for it.
Is INNER JOIN for Secondary Table fixed by design?

Regards,
Andrei.
 
 

_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Parent Message unknown OUTER JOIN to Secondary Table

by Andrei Shakirin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hello,
 
Is it any way in EclipseLink to make OUTER JOIN to Secondary Table?

Use case: There is a main employee table that may or may not have some extra data populated in a related secondary table. If there is data in the secondary table (@SecondaryTable), then I would like my Employee entity to have those fields filled in. If there isn't data for a given employee in the secondary table, then I would like my Employee entity to have nulls in those fields. Right now, if there's no row in the secondary table for a given employee, I get nothing.

Unfortunately I cannot find acceptable solution in Internet.
Is INNER JOIN for Secondary Table fixed by design?

Regards,
Andrei.
                
 
 

_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Re: OUTER JOIN to Secondary Table

by James Sutherland :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Normally if an outerjoin is desired, you should instead use a OneToOne relationship instead of a multiple table mapping.  The issue is just not in reading the class, but updating or inserting a row that may not be there is problematic.

If you must use a multiple table mapping, then you can use a DescriptorCustomizer to set the multipleTableJoinExpression for your descriptor to one using equalOuterJoin.

Another solution would be to define a view that does the other join and map to it.

See also,
http://en.wikibooks.org/wiki/Java_Persistence/Tables#Multiple_table_outer_joins

ashakirin wrote:
Is it any way in EclipseLink to make OUTER JOIN to Secondary Table?

Use case: There is a main employee table that may or may not have some extra data populated in a related secondary table. If there is data in the secondary table (@SecondaryTable), then I would like my Employee entity to have those fields filled in. If there isn't data for a given employee in the secondary table, then I would like my Employee entity to have nulls in those fields. Right now, if there's no row in the secondary table for a given employee, I get nothing.

Unfortunately I cannot find acceptable solution in Internet.
Is INNER JOIN for Secondary Table fixed by design?

Regards,
Andrei.