I have two tables, a Entity table and a table containing some data (also from other systems, not managed by JPA)
The entity table is like
ID ; Name ; Ref
-----------------
1 ; Test1 ; D1
2 ; Test2 ; D2
3 ; Test3 ; D3
The data table is like
EID ; Value
-------------
D1 ; Data1
D2 ; Data2
In my Entity I have defined
@SecondaryTable(name = "data", pkJoinColumns = @PrimaryKeyJoinColumn(name = "EID", referencedColumnName = "Ref"))
...
@Column(table = "data", name = "EID", updatable = false, insertable = false, nullable = true)
private String _external_data;
I'm fetching the Entities using NamedQueries. As long as I fetch Test1 or Test2 (IDs: 1,2) they are returned. Fetching Test3 (ID 3) doesn't work, as the external data table has no entries matching the Ref.
Is there any solution to also return entities with no mathing rows in the Data-table?