Hello I am trying to develop a solution using JPA Repositories to force a left outer join instead of an inner join. I am trying to do a query essentially to get all items in Table1 even if the join returns a null in table 2. When doing a basic CrudRepository call findAll, the inner join is used instead of the left join. Please note, I am only using this for view purposes only so I am thinking a unidirectional is ok. Any suggestions on how to use a left join to do this?
@Entity(name="Table1")
public class Table1 {
@Id
@GenericGenerator(name = "gen", strategy = "increment")
@GeneratedValue(generator = "gen")
@Column(name = "id")
private int Id;
@Column
private String tableName;
@Column
private Timestamp createTS;
@Column
private Timestamp updateTS;
@OneToMany
@JoinColumn(name ="table1Name" referencename="tableName")
private List<Table2> t2;
@Entity(name="Table2")
public class Table2 {
@Id
@GenericGenerator(name = "gen", strategy = "increment")
@GeneratedValue(generator = "gen")
@Column(name = "id")
private int Id;
@Column
private String table1Name;
@Column
private String attribute1;
@Column
private String attribute2;